Why am i not able to run this program ?

When i exec a single process it works fine but when i try to execute array of commands i couldn't it complies but doesn't execute any 1 of the commands.

Please let me know

import java.io.IOException;

class RunTime

{

public static void main(String raja[])

{

Runtime r = Runtime.getRuntime();

Process p;

String[] commands = { "notepad","calcic","mspaint"};

System.out.println("Executing processes please wait........");

try

{

int commandslength = commands.length;

for(int i = 0 ; i < commandslength ; i++)

p = r.exec("commands");

}

catch(Exception e)

{

System.out.println("Cant proceed furthur ..");

}

}

}

[759 byte] By [Raja_Datlaa] at [2007-10-3 3:31:12]
# 1
Use the "Code" formatting tags when posting code so the code is readable.You need to create a separate Process for each program you want to execute. The array is not used for a list of programs. Rather is used to invoke a program and pass a list of parameters to that program.
camickra at 2007-7-14 21:25:13 > top of Java-index,Java Essentials,Java Programming...
# 2
Instead ofp = r.exec("commands[i]");dop = r.exec(commands[i]);Next time please paste your code between [code] tags with the help of the code button just above the edit message area.It makes the code MUCH more
jfbrierea at 2007-7-14 21:25:13 > top of Java-index,Java Essentials,Java Programming...
# 3
Hi, Change your code like this p = r.exec(commands[i]); bye for nowsat
AnanSmritia at 2007-7-14 21:25:13 > top of Java-index,Java Essentials,Java Programming...