how to run shell command in java?
i want to run the shell command in java.Also help me how to run executable files of linux environment in java. As in "c" language we use "system" command to run shell command and executable file. How can i achieve it in Java???
|
Um, why would you want to since it pretty much defeats the purpose of writing a program in Java? Is there really no Java based way to do what you want?
|
you can use exec command.
Process processName=r1.exec("command"); processName.waitFor(); //sorry I clicked submit by accident |
I don't remember what you have to import but the command is "exec":
e.g: Runtime r=Runtime.getRuntime(); Process processName=r.exec("command"); processName.waitFor();//if you want to wait for it |
All times are GMT -5. The time now is 07:58 PM. |