【发布时间】:2013-02-01 09:38:33
【问题描述】:
我正在制作一个程序,它必须用clafer -m=xml Case5.cfr 调用Clafer。
所以我用
ProcessBuilder pb = new ProcessBuilder("clafer -m=xml " + "Case5.cfr");
pb.directory(new File("C:\\Users\\unituser\\workspace\\com.unitbilisim.clafer2Ecore\\src\\model\\"));
Process P = pb.start();
但总是出现以下错误:
Exception in thread "main" java.io.IOException: Cannot run program "clafer -m=xml Case5.cfr" (in directory "C:\Users\unituser\workspace\com.unitbilisim.clafer2Ecore\src\model"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at EmfCompare.emfCompareDeneme.main(emfCompareDeneme.java:54)
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>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 2 more
我不明白为什么。谁能帮帮我?
【问题讨论】:
-
您需要将程序名称与其参数分开,每个参数都需要位于字符串数组或字符串列表的不同字符串元素中。