This section explains how to execute a program from Java and read the output of that program back into your application. Just as a reminder, the use of OS commands in your code destroys portability.
If you can live with that limitation, there are four general steps to executing a program from your Java program.
Get the object representing the current run-time environment. A static method in class java.lang.Runtime does this.
exec method in the run-time object, with your command as an argument string. Give the full path name to the executable, and make sure the executable really exists on the system. The call to
exec() returns a Process object.
Connect the output of the Process (which ...