Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I run other programs using java program

843798Jun 28 2001 — edited Jun 28 2001
hi experts,
I am trying to execute a set of commands from java program

eg: from command prompt

java CommandExecutor c:\winnt\notepad.exe c:\some.exe c:\onemorecommand.exe

and inside the CommandExecutor main method..

public static void main(String []arg)
{
for(i = 0; i < arg.length; i++)
{
Runtime.getRuntime().exec(arg(i));
}
}

the above code is executing all the command one after the other, but I want to execute the above commands squentially, i.e I want to execute the second command only after finishing the first command and the third after finishing the second and so on depending upon the arguments passed, how can I acheive this...

I have tried to use the Process which is returned by the exec(arg) method but the exitValue() returns same value before execution and after execution.

thanks,
krishna

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 26 2001
Added on Jun 28 2001
1 comment
66 views