4
你好我試圖在Eclipse中運行以下CMD代碼:產生java.io.IOException:不能運行程序 「目錄」:CreateProcess的錯誤= 2,DAS系統
"DIR \""+DEV_HOME+"\\src\"\\*.java /b /s >> \""+DEV_HOME+"\\bin\\javaFiles.txt\""
在明確它看起來像這樣:
DIR "D:\Thomas\Dokumente\Daten\workspace\WBRLight\src"\*.java /b /s >> "D:\Thomas\Dokumente\Daten\workspace\WBRLight\bin\javaFiles.txt"
,但我得到以下錯誤消息:
java.io.IOException: Cannot run program "dir": CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at java.lang.Runtime.exec(Runtime.java:617)
at java.lang.Runtime.exec(Runtime.java:450)
....
當我嘗試使用代碼在cmd中,其工作的罰款。 我的代碼:
public void run_cmdLine(String command) {
try {
Runtime rt = Runtime.getRuntime();
BufferedReader input = null;
Process pr = null;
pr = rt.exec(command);
input = new BufferedReader(new inputStreamReader(pr.getInputStream()));
String line = null;
while ((line = input.readLine()) != null) {
System.out.println(line);
}
int exitVal = pr.waitFor();
System.out.println("Exited with error code " + exitVal);
} catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}
}
ok我現在糾正了:「cmd/c dir \」「+ DEV_HOME +」\ .....「它的工作 – user2889693
當我這樣做時,我什麼也得不到。 – santafebound