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 abstract class Process

  1. Object
  2. Process

ImplementsAutoCloseable

A child OS process. Stream directions and lifecycle methods follow JavaSE. Read stdout and stderr concurrently to avoid filling a pipe. Never wait or do blocking stream I/O on the EDT. Interrupting a wait does not kill the child. Unlike JavaSE, this class is AutoCloseable: close forcibly terminates the direct child and closes its three streams. Descendants are not terminated.

Constructors

public Process()

Methods

public abstract OutputStream getOutputStream()The child’s stdin (the parent writes to it).
public abstract InputStream getInputStream()The child’s stdout (the parent reads from it).
public abstract InputStream getErrorStream()The child’s stderr; EOF when redirectErrorStream(true) was selected.
public abstract int exitValue()Returns the exit code, or throws IllegalThreadStateException while alive.
public abstract void destroy()Requests termination of the direct child.
public abstract Process destroyForcibly()Forcibly terminates the direct child; completion is asynchronous.
public boolean isAlive()Whether the direct child is still running.
public int waitFor() throws InterruptedExceptionWaits for exit.
public boolean waitFor(long timeoutMillis) throws InterruptedExceptionWaits at most timeout milliseconds.
protected void pause(long millis) throws InterruptedExceptionPort hook for a bounded wait between exit polls.
public boolean waitFor(long timeout, TimeUnit unit) throws InterruptedExceptionJavaSE-style timed wait; sub-millisecond positive durations round up.
public void close() throws IOExceptionForcibly terminates the child and releases all pipes, even if one close fails.

Inherited methods

Constructor details

Process

public Process()

Method details

getOutputStream

public abstract OutputStream getOutputStream()
The child’s stdin (the parent writes to it).

getInputStream

public abstract InputStream getInputStream()
The child’s stdout (the parent reads from it).

getErrorStream

public abstract InputStream getErrorStream()
The child’s stderr; EOF when redirectErrorStream(true) was selected.

exitValue

public abstract int exitValue()
Returns the exit code, or throws IllegalThreadStateException while alive.

destroy

public abstract void destroy()
Requests termination of the direct child. On Windows this is forcible.

destroyForcibly

public abstract Process destroyForcibly()
Forcibly terminates the direct child; completion is asynchronous.

isAlive

public boolean isAlive()
Whether the direct child is still running.

waitFor

public int waitFor() throws InterruptedException
Waits for exit. An interrupt cancels only this wait.

waitFor

public boolean waitFor(long timeoutMillis) throws InterruptedException
Waits at most timeout milliseconds. Zero/negative values only poll.

pause

protected void pause(long millis) throws InterruptedException
Port hook for a bounded wait between exit polls.

waitFor

public boolean waitFor(long timeout, TimeUnit unit) throws InterruptedException
JavaSE-style timed wait; sub-millisecond positive durations round up.

close

public void close() throws IOException
Forcibly terminates the child and releases all pipes, even if one close fails. The runtime reaps it independently; this does not wait for termination.