commons-exec: Executing a program on the system PATH?

Posted by Stefan Kendall on Stack Overflow See other posts from Stack Overflow or by Stefan Kendall
Published on 2010-04-22T17:24:24Z Indexed on 2010/04/23 4:13 UTC
Read the original article Hit count: 316

I'm trying to execute a program (convert from ImageMagick, to be specific) whose parent folder exists on the path. Ergo, when I run convert from the command line, it runs the command. The following, however, fails:

String command = "convert"
CommandLine commandLine = CommandLine.parse(command);
commandLine.addArgument(...)
...
int exitValue = executor.execute(commandLine);

If I specify the full path of the convert executable (C:\Program files\...) then this code works. If I don't do this, I get an exception thrown with exit value 4.

How do I get commons-exec to recognize the system path?

© Stack Overflow or respective owner

Related posts about commons-exec

Related posts about java