There are two ways to let ProcessBuilder know which command to run:
- By passing the command and its options to the constructor while creating the ProcessBuilder object.
- By passing the command and its options as parameters to the command() method of the ProcessBuilder object.
Before spawning the process, we can do the following:
- We can change the directory of execution by using the directory() method
- We can redirect the input stream, output stream, and error streams to file or to another process
- We can provide the required environment variables for the subprocess
We will see all these activities in their respective recipes in this chapter.
A new process is spawned when the start() method is invoked and the caller gets a ...