Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public final class ProcessBuilder
- Object
- ProcessBuilder
Creates desktop/backend subprocesses using JavaSE-style command lists and pipes. The working directory is an OS path String, not a Codename One file URL. Shell parsing is never implicit: invoke a shell explicitly if needed. Mobile/browser ports compile this API but start() throws UnsupportedOperationException. Support does not imply permission to run every executable. Builders are mutable and are not thread safe.
File redirection and inheritIO are not provided in this initial subset. Use the streams and drain stdout/stderr concurrently, or merge them first.
Constructors
public ProcessBuilder(String... command) | |
public ProcessBuilder(List<String> command) |
Methods
public static boolean isSupported() | Whether this port implements subprocess creation (no Display init required). |
public List<String> command() | Returns the live command list, as in JavaSE. |
public ProcessBuilder command(List<String> command) | Keeps the supplied list, as in JavaSE. |
public ProcessBuilder command(String... command) | |
public ProcessBuilder directory(String directory) | Null inherits the parent’s working directory. |
public String directory() | |
public Map<String, String> environment() | A mutable copy of the inherited environment, initialized on first access. |
public ProcessBuilder redirectErrorStream(boolean merge) | |
public boolean redirectErrorStream() | |
public Process start()
throws IOException | Launches a child. |
Inherited methods
Constructor details
ProcessBuilder
public ProcessBuilder(String... command)ProcessBuilder
public ProcessBuilder(List<String> command)Method details
isSupported
public static boolean isSupported()Whether this port implements subprocess creation (no Display init required).
command
public List<String> command()Returns the live command list, as in JavaSE.
command
public ProcessBuilder command(List<String> command)Keeps the supplied list, as in JavaSE. Validated again at start().
command
public ProcessBuilder command(String... command)directory
public ProcessBuilder directory(String directory)Null inherits the parent’s working directory. Paths are native OS paths.
directory
public String directory()environment
public Map<String, String> environment()A mutable copy of the inherited environment, initialized on first access.
Changes are validated at start(), including changes through entrySet().
Throws UnsupportedOperationException on unsupported ports.
redirectErrorStream
public ProcessBuilder redirectErrorStream(boolean merge)redirectErrorStream
public boolean redirectErrorStream()start
public Process start()
throws IOExceptionLaunches a child. Invalid arguments throw IllegalArgumentException (or
NullPointerException); launch/permission errors throw IOException or
SecurityException. An unsupported port throws UnsupportedOperationException.