I am having troubles with Java\'s ProcessBuilder on an Eclipse plugin I\'m developing. I correctly set the environment before calling the start() method, but when I run the prog
I think, the environment you set on the ProcessBuilder is only what is passed to the new process but not what is used by the builder itself. Try setting the environment variables of your Java process before trying to start the new process.
Edit:
Seeing that it may not be possible to alter the Java process's environment, I believe you have to come up with some work-around.
When you already know the path(s) you are looking for you can of course figure out the full path to "my_command"
yourself, about so:
String commandString;
if ( new File(env1 + "/my_command").isFile() ) {
commandString = env1 + "/my_command";
} else
if ( new File(env2 + "/my_command").isFile() ) {
commandString = env2 + "/my_command";
}
ProcessBuilder pb = new ProcessBuilder(commandString, file, output);
Might be impractical though, if "my_command"
may already be in one of the user's PATH
elements.