Java Program to Shut Down Computer in Linux
In this program, we will shut down the Computer if the operating System is Linux. So, Firstly we will check that the System on which we are running Java Program is Linux or not. If the operating system is not Linux then we would not proceed further and print “Unsupported Operating System”. If it is a Linux operating system then the user will enter the time (in seconds) so that after that time PC would shut down.
Here time (in seconds) doesn’t include the time taken by Your System to shut down. For Example: if the user will input 1 sec then it consists of 1 second plus your system time required to shut down. This is because due to system architecture, availability of RAM, etc. affects the Shutting Down Speed.
- Import Required Packages.
- Check your PC has Linux Operating System or Not.
- If it is not Linux then print “Unsupported Operating System”.
- IF it is Linux the take input about “After how many seconds the PC will shut Down” to the user.
- PC will shut down.
Below is the implementation of the above approach:
Name of Operating System:Linux //Shutting Down your Linux system