Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2012
    Posts
    10
    Rep Power
    0

    Default Shutdown the system using java code

    I want to shutdown my computer using java code. The following code has no error but its not shutting down my system.

    import javax.swing.JOptionPane;
    public class Shutdown{
    public static void main(String[] args){
    try{
    Runtime rt = Runtime.getRuntime();
    Process pr = rt.exec("cmd /c shutdown -s");
    } catch (Exception ew){
    JOptionPane.showMessageDialog(null, ew.toString());
    ew.printStackTrace();
    }
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Shutdown the system using java code

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Please explain this System.out.println() code
    By RichersooN in forum New To Java
    Replies: 2
    Last Post: 10-11-2011, 05:12 AM
  2. Detect system shutdown/log off
    By cmpie1 in forum New To Java
    Replies: 0
    Last Post: 11-29-2010, 05:07 AM
  3. Remote shutdown using java.. Is it possible.. ?
    By point_Base in forum Eclipse
    Replies: 10
    Last Post: 02-22-2010, 03:11 AM
  4. code migration problem in distributing system
    By sushil in forum AWT / Swing
    Replies: 2
    Last Post: 10-29-2009, 01:34 PM
  5. Code compiles in/runs in IDE but not on UNIX system
    By Unclejunebug in forum New To Java
    Replies: 7
    Last Post: 10-08-2009, 08:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •