Skip to main content

exec() Problem

1 reply [Last post]
ribs15183
Offline
Joined: 2006-02-17
Points: 0

I'm having a strange problem with exec(). The program that exec is calling creates 4 output files. When I run this program from the command line, these files are created fine. However, when using exec(), the program is running (as seen in task manager) but the output files are not created anywhere. Any ideas on what could be casuing this?

code:

try {
System.out.print ("Running: ");
System.out.println(command);
System.out.print ("in working directory: ");
System.out.println(workingDir.getCanonicalPath());
Runtime.getRuntime().exec("agent.exe", null, workingDir);
answers.iclAddToList(
new IclStruct("ga_v2", goal.iclNthTerm(1)));
answer = true;
}
catch (Exception e) {
System.out.println("ga_v2 execution failed.");
e.printStackTrace();
answer = false;
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
zander
Offline
Joined: 2003-06-13
Points: 0

Does your application produce output? On the command line I mean.

Then try reading the bytes from the outputstream. (See the Process class you get from the exec call)