Process p = new ProcessBuilder("m圜ommand", "myArg").start() Starting a new process which uses the default working directory If multiple threads access a ProcessBuilder instanceĬoncurrently, and at least one of the threads modifies one of theĪttributes structurally, it must be synchronized externally. Note that this class is not synchronized. For example, setting the command attribute toĪn empty list will not throw an exception unless start() It is possible to modify the state of an object so that start() will fail. Most error checking is performed by the start() method. Will never affect previously started processes or the Java process Subsequently started by that object's start() method, but Modifying a process builder's attributes will affect processes the stream returned from Process.getErrorStream() will.Method is ignored when creating a subprocess the common destination of standard error and standard output can be.To the same destination (this makes it easier to correlate error standard error is merged with the standard output and always sent.Output of a subprocess are sent to two separate streams, which canīe accessed using the Process.getInputStream() and Process.getErrorStream() methods. Is false, meaning that the standard output and error Process.getErrorStream() will return a null input In this case, Process.getInputStream() and/or Standard error may be redirected to other destinations using Via the input streams returned by Process.getInputStream() and By default, the subprocess writes standard In this case, Process.getOutputStream() will return aĪnd standard error. Java codeĬan access this pipe via the output stream returned by Working directory of the current process, usually the directoryīy default, the subprocess reads input from a pipe. The environment of the current process (see System.getenv()). an environment, which is a system-dependent mapping from.Require commands to contain exactly two elements. Strings themselves - on such a system a Java implementation might
Systems where programs are expected to tokenize command line For example, it is common for each conceptualĪrgument to be an element in this list, but there are operating Which string lists represent a valid operating system command is
a command, a list of strings which signifies theĮxternal program file to be invoked and its arguments, if any.To create new subprocesses with identical or related attributes.Įach process builder manages these process attributes: The start() method can be invoked repeatedly from the same instance This class is used to create operating system processes.Įach ProcessBuilder instance manages a collection