View Full Version : Executing shell commands from java

Apr 3, 2007, 02:08 AM
how to execute a shell command from java on a mac machine..

thanks in advance

Apr 3, 2007, 02:21 AM
The same way as any other machine. Via Runtime (http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html) exec methods. The return a Process (http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Process.html) object which gives you access to stdin, stdout and stderr of the process. Wrap these in BufferedReader/Writer objects and you are good to go.