Class ProcessBuilder

java.lang.Object
com.codename1.io.ProcessBuilder

public final class ProcessBuilder extends Object

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.

  • 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 IOException
      Launches a child. Invalid arguments throw IllegalArgumentException (or NullPointerException); launch/permission errors throw IOException or SecurityException. An unsupported port throws UnsupportedOperationException.
      Throws:
      IOException