[FIXED] Shutting down a computer

Issue

Is there a way to shutdown a computer using a built-in Java method?

Solution

Create your own function to execute an OS command through the command line?

For the sake of an example. But know where and why you’d want to use this as others note.

public static void main(String arg[]) throws IOException{
    Runtime runtime = Runtime.getRuntime();
    Process proc = runtime.exec("shutdown -s -t 0");
    System.exit(0);
}

Answered By – David McGraw

Answer Checked By – Willingham (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published