The Runtime.exec() method allows Java apps. to create a new OS Process.
The Runtime.exec(...)
method (which has 6 overloaded variants) allows Java apps. to create a new system process (represented in Java as a Process
).
There are common mistakes made when creating new processes - as detailed in When Runtime.exec() won't. The article is the first thing to check if a process fails. Implement all the tips, and even if doing so does not make the process work, it will provide much more detailed information on why it failed.
The ProcessBuilder
class introduced in Java 1.5 makes it easier to create and use a process correctly. For example, the redirectErrorStream(boolean)
convenience method will merge the System.out
& System.err
streams, which allows both streams to be consumed in one Thread
.