Apache Commons Exec:不在PATH中的可执行文件

时间:2014-09-28 19:18:36

标签: apache-commons-exec

如何执行不在系统路径上的程序(我不想把它放在那里)?例如。最简单的例子:

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 ".")

(对于PATH上的程序也是如此,例如。" / usr / bin / ls"失败并显示相同的消息。)

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

1 个答案:

答案 0 :(得分:-1)

我的程序路径错误(ls不在/usr/bin),但错误消息误导我 - 它根本没有在工作目录中查找可执行文件