[英]Java Execute external exe
我有这个:
Runtime.getRuntime().exec("toolUpdate.exe", null, new File(location));
我得到以下错误:
java.io.IOException:无法运行程序“ toolUpdate.exe”(在目录“ C:\\ Users \\ blah \\ AppData \\ Roaming”中):CreateProcess错误= 2,系统找不到指定的文件
如果查看目录,我会看到我想要执行的文件,只是无法使用上面的代码来执行该文件。
这为我工作:
String folder = location;
String exe = "test.exe";
ProcessBuilder p = new ProcessBuilder();
p.command(folder + exe);
p.start();
我认为您可以通过以下代码更改来解决方法1。
Runtime.getRuntime().exec(location + "toolUpdate.exe");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.