【发布时间】:2019-09-24 16:02:29
【问题描述】:
我已经查看了如何通过运行时进程构建器在 java 中运行可执行文件,但它不起作用。 我的代码如下...
String command = "potrace --svg mb-finer-19.pbm -o mb-finer-19.svg";
try {
File f = new File("C:\\webstudio\\potrace113win32");
Process process = Runtime.getRuntime().exec(command, null, f);
System.out.println("the output stream is " + process.getOutputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String s;
while ((s = reader.readLine()) != null) {
System.out.println("The inout stream is " + s);
}
} catch (IOException e) {
e.printStackTrace();
}
但我回来了
java.io.IOException: Cannot run program "potrace" (in directory "C:\webstudio\potrace113win32"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:450)
at shellcommands.RunPotrace.main(RunPotrace.java:22)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)```
根据 javadocs,我在哪里出错了? 可执行的 portace.exe 与映像 mb-finer-19.pbm 一起位于目录中 非常感谢您的帮助。
【问题讨论】: