我有这样的代码:与选择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