How to execute a batch file from java?

前端 未结 7 493
逝去的感伤
逝去的感伤 2020-12-09 20:42

I want to execute a batch file from a java program.

I am using the following command.

Runtime.getRuntime().exec(\"server.bat\");

Bu

7条回答
  •  鱼传尺愫
    2020-12-09 20:49

    You can try it with Desktop if supported (Java 1.6)

        File file = new File("server.bat");
        Desktop.getDesktop().open(file);
    

提交回复
热议问题