更新时间:2022-12-16 07:47:29
在运行Java和您使用的Runtime.exec()使用相对路径,相对于当前用户的猪病,其中JVM被调用相对的手段。
When Java is running and you use Runtime.exec() with a relative path, relative means relative to the current user direcory, where the JVM was invoked.
这可能工作
Runtime.getRuntime().exec("cmd.exe", "/c", "./com/projct/util/server.bat");
如果你开始从COM的父目录的java。
if you start java from com's parent directory.
或者你必须计算的绝对路径:
Or you must calculate an absolut path:
Runtime.getRuntime().exec("cmd.exe", "/c",
System.getProperty("user.dir")+"/com/projct/util/server.bat");
我忘了,请参阅运行时.exec()将不会的。