Taking control of external processes
Up to JDK 9, if you wanted to create a Java process and handle process input/output, you had to use either the Runtime.getRuntime.exec()
method, which allows us to execute a command in a separate OS process and get a java.lang.Process
instance over which to provide certain operations in order to manage the external process, or use the new java.lang.ProcessBuilder
class with some more enhancements in regard to interacting with the external process and also create a java.lang.Process
instance to represent the external process. Both mechanisms were inflexible and also non-portable as the set of commands executed by the external processes were highly dependent on the operating system (additional effort had to be exerted in order to make the particular process operations portable across multiple operating systems). A chapter is dedicated to the new process API, providing developers with the knowledge of creating and managing external processes in a much easier way.