Interface ProcessAgent.ProcessBuilder
- Enclosing interface:
- ProcessAgent
start()
method creates a
new Process instance with those attributes. The start()
method can be invoked repeatedly from the same
instance to create new subprocesses with identical or related attributes.- Since:
- 5.0.5
-
Method Summary
Modifier and TypeMethodDescriptioncommand()
Returns this process builder's operating system program and arguments.Sets this process builder's operating system program and arguments.Sets this process builder's operating system program and arguments.Sets the specified name-value-pair to theenvironment()
.Returns a string map view of this process builder's environment.redirectOutput
(@Nullable String prefix) Redirectserror
andnormal output
to the log.start()
Spawn a new process with the current configuration.
-
Method Details
-
command
Returns this process builder's operating system program and arguments. The returned list is not a copy. Subsequent updates to the list will be reflected in the state of this process builder.- Returns:
- This process builder's program and its arguments
- Since:
- 5.0.5
-
command
Sets this process builder's operating system program and arguments. This method does not make a copy of the command list. Subsequent updates to the list will be reflected in the state of the process builder. It is not checked whether command corresponds to a valid operating system command.- Returns:
- This process builder
- Since:
- 5.0.5
-
command
Sets this process builder's operating system program and arguments. This is a convenience method that sets the command to a string list containing the same strings as the command array, in the same order. It is not checked whether command corresponds to a valid operating system command.- Parameters:
command
- A string array containing the program and its arguments- Returns:
- This process builder
- Since:
- 5.0.5
-
environment
Returns a string map view of this process builder's environment. Whenever a process builder is created, the environment is initialized to a copy of the current process environment (seeSystem.getenv()
. Subprocesses subsequently started by this object'sstart()
method will use this map as their environment.The returned object may be modified using ordinary Map operations. These modifications will be visible to subprocesses started via the
start()
method. Two ProcessBuilder instances always contain independent process environments, so changes to the returned map will never be reflected in any other ProcessBuilder instance or the values returned bySystem.getenv()
.If the system does not support environment variables, an empty map is returned.
- Since:
- 5.0.5
-
env
Sets the specified name-value-pair to theenvironment()
.- Returns:
- This process builder
- Since:
- 5.0.5
-
redirectOutput
Redirectserror
andnormal output
to the log.When redirected, the methods
getInputStream()
andgetErrorStream()
of the process instance provided bystart()
are no longer supported and will throw anIllegalStateException
.- Parameters:
prefix
- Prefix to use for redirected log messages.- Returns:
- This process builder
- Since:
- 5.0.5
-
start
Spawn a new process with the current configuration. The new process will invoke the command and arguments given bycommand()
, with a process environment as given byenvironment()
.Starting an operating system process is highly system-dependent. Among the many things that can go wrong are:
- The operating system program file was not found.
- Access to the program file was denied.
IOException
.Subsequent modifications to this process builder will not affect the returned
Process
.- Throws:
NullPointerException
- If an element of the command list is nullIndexOutOfBoundsException
- If the command is an empty list (has size 0)SecurityException
- If a security manager exists and its checkExec method doesn't allow creation of the subprocessIOException
- If an I/O error occurs- Since:
- 5.0.5
-