2014-09-28 76 views
0

如何執行不在系統PATH中的程序(並且我不想將它放在那裏)?例如。最簡單的例子:Apache Commons Exec:不在PATH中的可執行文件

String program = "/my/path/to/my/program"; 
new DefaultExecutor().execute(CommandLine.parse(program)); 

拋出

java.io.IOException: Cannot run program "/my/path/to/my/program" (in directory ".") 

(這同樣適用與在路徑,例如程序 「的/ usr /斌/ LS」 失敗,同樣的信息。)

注意:我不想更改工作目錄。

回答

-1

我的程序路徑錯誤(並且ls不在/usr/bin中),但是錯誤消息誤導了我 - 它根本沒有在工作目錄中查找可執行文件。

相關問題