我有這樣的代碼:與選擇Java運行C程序
try {
Process p = new ProcessBuilder(
"/Applications/TorBrowser_en-US.app/Contents/MacOS/./tor",
"-f /Applications/TorBrowser_en-US.app/Library/filetctor/torrc")
.start();
p.waitFor();
int exitVal = p.exitValue();
System.out.println("Process exitValue: " + exitVal);
} catch (IOException e) {
System.out.println(e);
} catch (InterruptedException e) {
System.out.println(e);
}
每次我執行它,我得到一個255 exitValue。該進程無法正常運行。
如果我運行只有程序:
Process p = new ProcessBuilder("/Applications/TorBrowser_en-US.app/Contents/MacOS/./tor").start();
過程正常運行。但我需要使用-f選項。
什麼問題?我寫錯了嗎?
的'-f'和文件路徑幾乎可以肯定應該是獨立的參數。 –
您是否嘗試自行運行該應用程序?它返回什麼錯誤?嘗試使用'getInputStream()'或'getErrorStream()'獲取它。 – Djon