Java Runtime command line Process
Posted
by AEIOU
on Stack Overflow
See other posts from Stack Overflow
or by AEIOU
Published on 2010-04-09T19:50:49Z
Indexed on
2010/04/09
19:53 UTC
Read the original article
Hit count: 455
I have a class with the following code:
Process process = null;
try {
process = Runtime.getRuntime().exec("gs -version");
System.out.println(process.toString());
} catch (Exception e1) {
e1.printStackTrace();
} finally {
process.destroy();
}
I can run "gs -version" on my command line and get: GPL Ghostscript 8.71 (2010-02-10) Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
So I know I have the path at least set somewhere.
I can run that class from command line and it works. But when I run it using eclipse I get the following error: java.io.IOException: Cannot run program "gs": error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:459) at java.lang.Runtime.exec(Runtime.java:593) at java.lang.Runtime.exec(Runtime.java:431) at java.lang.Runtime.exec(Runtime.java:328) at clris.batchdownloader.TestJDBC.main(TestJDBC.java:17) Caused by: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.(UNIXProcess.java:53) at java.lang.ProcessImpl.start(ProcessImpl.java:91) at java.lang.ProcessBuilder.start(ProcessBuilder.java:452) ... 4 more
In my program, i can replace "gs" with: "java", "mvn", "svn" and it works. But "gs" does not. It's only in eclipse I have this problem.
Any ideas, on what I need to do to resolve this issue?
© Stack Overflow or respective owner