Package jnr.process
Class ProcessBuilder
java.lang.Object
jnr.process.ProcessBuilder
ProcessBuilder mimics the API of the JDK
ProcessBuilder
class, providing methods to build up and
launch a child process.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionProcessBuilder
(String... command) Create a new ProcessBuilder instance with the given command line.ProcessBuilder
(List<String> command) Create a new ProcessBuilder instance with the given command line. -
Method Summary
Modifier and TypeMethodDescriptioncommand()
Get a copy of the list of command line arguments that will be used to launch the child process.Replace the command line with the given varargs array of command line arguments.Replace the command line with the given list of command line arguments.Returns a string map view of this process builder's environment.start()
Launch the subprocess and return a newProcess
instance.
-
Field Details
-
command
-
env
-
posix
private static final jnr.posix.POSIX posix
-
-
Constructor Details
-
ProcessBuilder
Create a new ProcessBuilder instance with the given command line.- Parameters:
command
- the command line as a list of string arguments
-
ProcessBuilder
Create a new ProcessBuilder instance with the given command line.- Parameters:
command
- the command line as a varargs array of string arguments
-
-
Method Details
-
command
Get a copy of the list of command line arguments that will be used to launch the child process.- Returns:
- a copied list of command line arguments
-
command
Replace the command line with the given list of command line arguments.- Parameters:
command
- the new list of command line arguments- Returns:
- this ProcessBuilder instance
-
command
Replace the command line with the given varargs array of command line arguments.- Parameters:
command
- the new array of command line arguments- Returns:
- this ProcessBuilder instance
-
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
operators.- Returns:
- The process builder's environment.
-
start
Launch the subprocess and return a newProcess
instance.- Returns:
- a new Process wrapping the child process's pid and IO streams
-