public static interface ProcessAgent.ProcessBuilder
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.Modifier and Type | Method and Description |
---|---|
List<String> |
command()
Returns this process builder's operating system program and arguments.
|
ProcessAgent.ProcessBuilder |
command(List<String> command)
Sets this process builder's operating system program and arguments.
|
ProcessAgent.ProcessBuilder |
command(String... command)
Sets this process builder's operating system program and arguments.
|
ProcessAgent.ProcessBuilder |
env(String name,
String value)
Sets the specified name-value-pair to the
environment() . |
Map<String,String> |
environment()
Returns a string map view of this process builder's environment.
|
ProcessAgent.ProcessBuilder |
redirectOutput(String prefix)
Redirects
error and normal output to
the log. |
Process |
start()
Spawn a new process with the current configuration.
|
List<String> command()
ProcessAgent.ProcessBuilder command(List<String> command)
ProcessAgent.ProcessBuilder command(String... command)
command
- A string array containing the program and its argumentsMap<String,String> environment()
System.getenv()
.
Subprocesses subsequently started by this object's start()
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 by System.getenv()
.
If the system does not support environment variables, an empty map is returned.
ProcessAgent.ProcessBuilder env(String name, String value)
environment()
.ProcessAgent.ProcessBuilder redirectOutput(@Nullable String prefix)
error
and normal output
to
the log.
When redirected, the methods getInputStream()
and getErrorStream()
of the process instance provided by start()
are no longer
supported and will throw an IllegalStateException
.
prefix
- Prefix to use for redirected log messages.Process start() throws IOException
command()
,
with a process environment as given by environment()
.Starting an operating system process is highly system-dependent. Among the many things that can go wrong are:
IOException
.
Subsequent modifications to this process builder will not affect the returned Process
.
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 occursCopyright © 2014 e-Spirit AG. All Rights Reserved. Build 5.0_BETA.500