Java Program To Shutdown Computer
Chapter:
Miscellaneous
Last Updated:
28-10-2016 13:14:04 UTC
Program:
/* ............... START ............... */
import java.io.*;
public class JavaShutdownComputer {
public static void main(String args[]) throws IOException {
Runtime runtime = Runtime.getRuntime();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter No. of Seconds after which You "
+ "want your Computer to Shutdown :");
long a = Long.parseLong(br.readLine());
Process proc = runtime.exec("shutdown -s -t " + a);
System.exit(0);
}
}
/* ............... END ............... */
Notes:
-
To shutdown computer in Java programming, you have to use the command shutdown -s -t. You can also specify the time after which you want to make your computer turn off or shutdown.
Tags
Java Program To Shutdown Computer, Java, Miscellaneous