用java程序,如何关机,重启机器

解决方案 »

  1.   

    Runtime.getRuntime().exec("shutdown -t now");
    Runtime.getRuntime().exec("reboot");windows里面同样可以使用类似的命令
      

  2.   

    windows下
    Runtime.getRuntime().exec("shutdown /s /t 0");
    Runtime.getRuntime().exec("shutdown /r");
      

  3.   

    Runtime.getRuntime().exec("shutdown -t now");
    --------------------------------------------------
    参数错误了,
    shutdown -h now