Procrun is a library for running an OS process and obtaining its exit status, standard output output, and standard error output.

The ProcessBuilder and Process classes from the java.lang package provide a start, but there are a number of additional things that must be done to correctly run a process and read its output. Procrun fills this gap.

Procrun provides the following features:

  1. Ensures the process is terminated on exception or interruption
  2. Ensures the process is terminated on VM exit
  3. Process can be run and terminated by interacting with a single class instance
  4. Reads promptly from the process' standard output and standard error to keep the process from blocking or deadlocking
  5. Can read the process' output in various ways: reading and discarding, reading into a growing buffer, and reading into a fixed-size buffer (suitable for limiting the amount of memory used)
  6. Static convenience methods for a short way to run a process and get a result