Page 1 of 1

using IM commands from Java

Posted: 2012-04-09T13:04:36-07:00
by gaurav_kl
I am trying to run a simple IM command from a Java class and as I have to run only a few commands I thought
instead of using Im4Java ,I could directly use ProcessBuilder.start().
I am using the following code-

Code: Select all

ProcessBuilder pb = new ProcessBuilder("convert","pic2.png","pic52.png");
			 pb.directory(new File("/user/gaurav_kl"));
			pb.start();
but I am getting the error
IOException - Cannot run program "convert" (in directory "/user/gaurav_kl"): error=2, No such file or directory
What could be the reason.
when I run the same command from terminal it works fine from any Dir as IM has been added to classpath

Re: using IM commands from Java

Posted: 2012-04-09T13:48:15-07:00
by fmw42
try putting in the full path to convert

if you do not know it, type at a console

type -a convert

or

which convert

Re: using IM commands from Java

Posted: 2012-04-09T14:20:22-07:00
by gaurav_kl
thanks.it worked.
i had thought it was already added in the PATH .

Re: using IM commands from Java

Posted: 2012-04-09T15:00:46-07:00
by fmw42
Many scripting systems do not check the PATH. Typical with PHP, Applescript, etc