Forum Stats

  • 3,759,037 Users
  • 2,251,494 Discussions
  • 7,870,477 Comments

Discussions

How can I run other programs using java program

843798
843798 Member Posts: 24,864
edited Jun 28, 2001 12:22PM in Java Runtime Environment (JRE)
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

This discussion has been closed.