The redirection operator ">" is interpreted by the shell, and your exec
call doesn't go through a shell. Try this:
String[] cmds = { "sh", "-c", "ppmtogif inputfile.ppm >
outputfile.gif" };
Runtime.getRuntime().exec(cmds);
This will run a shell that will interpret your command line. There are
other solutions that don't involve running an external shell, but this
is the simplest.
Nathan
Yuet Sim Lee wrote:
>
> I am trying to make my Java code
> to exec another Unix program.
> The command in Unix/Linux platform
> is:
>
> "ppmtogif inputfile.ppm > outputfile.gif"
>
> The command will create a new output file
> storing a gif formatted image.
> However, I tryed the following in my
> Java code:
>
> String command = "ppmtogif inputfile > outputfile";
> try {
> Process GUIP = Runtime.getRuntime().exec(command);
> } // End for try
>
> It does not do work.
>
> --Sim
>
> --
> Yuet Sim Lee
>
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]