I want to shutdown my computer using java code. The following code has no error but its not shutting down my system.
import javax.swing.JOptionPane;
public class Shutdown{
public static void main(String[] args){
try{
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("cmd /c shutdown -s");
} catch (Exception ew){
JOptionPane.showMessageDialog(null, ew.toString());
ew.printStackTrace();
}
}
}
