using IM commands from Java

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
gaurav_kl
Posts: 14
Joined: 2012-03-28T12:28:56-07:00
Authentication code: 8675308

using IM commands from Java

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: using IM commands from Java

Post 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
gaurav_kl
Posts: 14
Joined: 2012-03-28T12:28:56-07:00
Authentication code: 8675308

Re: using IM commands from Java

Post by gaurav_kl »

thanks.it worked.
i had thought it was already added in the PATH .
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: using IM commands from Java

Post by fmw42 »

Many scripting systems do not check the PATH. Typical with PHP, Applescript, etc
Post Reply