I am trying to run the following code from Eclipse:
Process process = Runtime.getRuntime().exec("gs");
However, I get an exception:
java.io.IOException: cannot start program "gs": error = 2, There is no such file or directory
Running gs from the command line (OS X) works fine with any directory like on my PATH. Eclipse does not seem to know about my path environment variable, although I went into the startup configuration and selected PATH on the environment tab.
In addition to debugging this problem, I tried the following code:
Process process = Runtime.getRuntime().exec("echo $PATH");
InputStream fromStdout = process.getInputStream();
byte[] byteArray = IOUtils.toByteArray(fromStdout);
System.out.println(new String(byteArray));
The output was $ PATH, hmm. Can someone push me in the right direction?
source
share