call()method. You can also (re)configure the builder and spawn a different process.
Note the API does not prescribe the actual meaning of
It may be local process, remote process or some other implementation.
You can use the default implementation returned by
for creating the local machine OS processes.
Thread safety of this class depends on thread safety of
ProcessBuilderImplementation the class is using. If it is thread
safe (if possible the implementation should be even stateless) this class
is thread safe as well.
|Modifier and Type||Method and Description|
Creates the new
Returns the human readable description of this builder.
Sets the arguments passed to the process created by subsequent call of
Sets the environment variables for the process created by subsequent call of
Sets the executable to run.
Sets the additional paths to be included in
Configures the error stream redirection.
Sets the working directory for the process created by subsequent call of
public static ProcessBuilder getLocal()
ProcessBuildercreating the OS process on local machine. Returned implementation is
ProcessBuildercreating the OS process on local machine
IllegalStateExceptionwhen there is no executable configured.
executable- the executable to run
public void setWorkingDirectory(@NullAllowed String workingDirectory)
call(). The default value is implementation specific.
workingDirectory- the working directory of the process
call(). By default there are no arguments.
arguments- the arguments passed to the process
call(). By default there are no environment variables with exception of
PATHpossibly configured by
envVariables- the environment variables for the process
PATHenvironment variable for the process.
paths- the additional paths to be included in
public void setRedirectErrorStream(boolean redirectErrorStream)
truethe error stream of process created by subsequent call of
call()method will be redirected to standard output stream.
redirectErrorStream- the error stream redirection
@NonNull public Process call() throws IOException
Processbased on the properties configured in this builder.
Actual behavior depends on the builder implementation, but it should respect all the properties configured on this builder.
Since version 1.35 implementors of this method are advised to throw
UserQuestionException in case the execution cannot be
performed and requires additional user confirmation, or configuration.
Callers of this method may check for this exception and handle it
Processbased on the properties configured in this builder
IOException- if the process could not be created
IllegalStateException- if there is no executable configured by
UserQuestionException- if the execution cannot be performed without permission from the user
Built on August 25 2014. | Portions Copyright 1997-2014 Oracle. All rights reserved.