Class DefaultExecutor

java.lang.Object
org.apache.commons.exec.DefaultExecutor
All Implemented Interfaces:
Executor
Direct Known Subclasses:
DaemonExecutor

public class DefaultExecutor extends Object implements Executor
The default class to start a subprocess. The implementation allows to
  • set a current working directory for the subprocess
  • provide a set of environment variables passed to the subprocess
  • capture the subprocess output of stdout and stderr using an ExecuteStreamHandler
  • kill long-running processes using an ExecuteWatchdog
  • define a set of expected exit values
  • terminate any started processes when the main process is terminating using a ProcessDestroyer
The following example shows the basic usage:
 Executor exec = DefaultExecutor.builder().get();
 CommandLine cl = new CommandLine("ls -l");
 int exitvalue = exec.execute(cl);