To shutdown a PC from a java program ,we may use Runtime.getRuntime() & executes a process shutdown (just like from cmd) :
CODE :
class ShutDownCode
{
public static void main(String a[])
{
try
{
Runtime.getRuntime().exec(“shutdown.exe -s -t 0”);
}catch(Exception e)
{
System.out.println(e);
}
}
}
Above code will shutdown the PC when the program is executed.