Why execute commands in console failed?
Hello Sir:
I want to run some commnads in console from Java Application, but I can only run simple one such as notepad etc, I cannot execute java and other commands such as dir or path etc,
see code below,
can somebody here help what is wrong here?
publicclass RuntimeGetRuntime{
publicstaticvoid main(String args[]){
Runtime r = Runtime.getRuntime();
Process p =null;
String cmd1[] ={"notepad","src/aaa/ReadFile.java"};
String cmd2[] ={"java","-version"};
String cmd3[] ={"cmd /c java","bin.aaa.ReadFile"};
String cmd[] ={"path"};
try{
p = r.exec(cmd);
System.out.println("Test aaaaa");
}catch (Exception e){
System.out.println("error executing " + cmd[0]);
}
}
}
here only cmd1 ok, all others failed.
Why?
Thanks in advance

