In this post, I will explain about a Java program to shutdown computer. This is a very basic program in Java programming language. If you are Java beginners or want to start learning Java programming language, then this program will help you to understand the basic Java programming.
Before executing this program I assume you have configured Java in your computer. Copy the below program and create a file “ShutdownComputer.java” and execute it to shut down your computer.
public class ShutdownComputer
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:");
Process proc = runtime.exec("shutdown -s -t " +a);
Liked this tutorial? Do Like & share with your friends 🙂