You can write a simple code in Java and create a Shut Down timer system for your computer. But before you execute the code, make sure you have already installed JDK on your system

Either you can execute this code inside IDEs like Eclipse and Microsoft’s Visual Studio Code, or if you don’t want to compromise with space, you can go with Notepad. 

Open Notepad, type this simple Java code and save the file with the .java extension inside your ideal location. Open the command prompt in Windows or terminal for Mac, set the directory and execute the program. If you forgot how to compile and run a java program, see this guide.

Java source code to shut down a computer

Compiling and running a Java program is the same for all Operating Systems. The only variation comes when you need to set the path for JDK. 

You can make the statements comment that you don’t want to execute. For instance, if you only want to shut down your system after a specific period of time, make all the other shut down and restart statements a comment by attaching // as a prefix except r.exec(“shutdown -s -t 10”);

Also See:

How to Shut Down your Computer by pulling down your screen?