Is it possible to shutdown Windows programmatically with Java?
Cheers
String shutdownCmd = "shutdown -s";
Process child = Runtime.getRuntime().exec(shutdownCmd);
More information on the shutdown command for your viewing pleasure
Some other command line options that may be of interest to you are
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-r Shutdown and restart the computer
-m \computername (Remote computer to shutdown/restart/abort)
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
Of course, if you prefer to not do it this method, there are libraries you can download to achieve this. One example of this would be Java Windows Shutdown Functions.
According to their SourceForge page:
JWSF - Java Windows Shutdown Functions API allows java applications to perform the following operations on most windows operating system, shutdown, restart, logoff, lock workstation. JWSF makes native calls using JNI. JWSF is subject to the LGPL license