Possible Duplicate:
run shell command from java
I’m trying to run a process with some arguments from inside Java and before running the particular command I print it using println.
Now the problem is from inside Java, the process is not doing good.. its sending some error on the Error Stream instead of output. But If I run the same command printed by Java on screen in console, it works perfectly.
String command="abc -def -hhij";
System.out.println(command);
Process p = Runtime.getRuntime.exec(command);
Anyone know whats going on wrong?
The Runtime.exec(String) using the StringTokenizer, which doesn’t know how to process quoted text. The simplest fix is to use the exec that accepts your parameters in an array.