L
Leigh Riley
I have a command line Java program that I run by typing: "java runExtrol
-i file.in -o file.out". I am writing a test class and would like to run
it from within Java using exec() e.g.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
String command = "java runExtrol -i file.in -o file.out";
try
{
Process px = Runtime.getRuntime().exec(command);
BufferedReader buf = new BufferedReader(new
InputStreamReader(px.getInputStream()));
String line;
while ((line = buf.readLine()) != null)
System.out.println(line);
px.waitFor();
px.destroy();
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The above code doesn't fail, but it doesn't output what runExtrol
should. When I replace the command with "ping", I get output back
telling me how to use ping properly. When I use "did" I get a
java.io.IOException: CreateProcess: dir error=2. I've tried fully
qulaifying the paths, but I still don't get any output. Can anyone think
of anything that I may be doing wrong?
Thanks very much in advance for any replies!!!
- Best regards,
Leigh
-i file.in -o file.out". I am writing a test class and would like to run
it from within Java using exec() e.g.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
String command = "java runExtrol -i file.in -o file.out";
try
{
Process px = Runtime.getRuntime().exec(command);
BufferedReader buf = new BufferedReader(new
InputStreamReader(px.getInputStream()));
String line;
while ((line = buf.readLine()) != null)
System.out.println(line);
px.waitFor();
px.destroy();
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The above code doesn't fail, but it doesn't output what runExtrol
should. When I replace the command with "ping", I get output back
telling me how to use ping properly. When I use "did" I get a
java.io.IOException: CreateProcess: dir error=2. I've tried fully
qulaifying the paths, but I still don't get any output. Can anyone think
of anything that I may be doing wrong?
Thanks very much in advance for any replies!!!
- Best regards,
Leigh