我尝试使用“eclipse”作为命令运行ProcessBuilder,它对我来说很好。但是当同一个eclipse被重命名为eclipsetest并且ProcessBuilder以eclipsetest作为命令运行时,我得到一个IOException
代码是::
ProcessBuilder pb = new ProcessBuilder("eclipsetest");
pb = pb.directory("/home/test/eclipse");
pb.start();
堆栈跟踪是: -
Exception in thread "main" java.io.IOException: Cannot run program "eclipsetest" (in directory "/home/test/eclipse"):java.io.IOException:
error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at com.test.util.EclipseProcess.main(EclipseProcess.java:27)
Caused by: java.io.IOException: java.io.IOException:
error=2, No such file or directory at java.lang.UNIXProcess.<init>(UNIXProcess.java:148) at java.lang.ProcessImpl.start(ProcessImpl.java:65) at
java.lang.ProcessBuilder.start(ProcessBuilder.java:452) ... 1 more