Interface CommandLauncher

All Known Implementing Classes:
CommandLauncherImpl, CommandLauncherProxy, Java13CommandLauncher, OS2CommandLauncher, VmsCommandLauncher, WinNTCommandLauncher

public interface CommandLauncher
Interface to shield the caller from the various platform-dependent implementations.
Version:
$Id: CommandLauncher.java 1636056 2014-11-01 21:12:52Z ggregory $
  • Method Summary

    Modifier and Type
    Method
    Description
    Launches the given command in a new process.
    exec(CommandLine cmd, Map<String,String> env, File workingDir)
    Launches the given command in a new process, in the given working directory.
    boolean
    isFailure(int exitValue)
    Checks whether exitValue signals a failure on the current system (OS specific).
  • Method Details

    • exec

      Launches the given command in a new process.
      Parameters:
      cmd - The command to execute
      env - The environment for the new process. If null, the environment of the current process is used.
      Returns:
      the newly created process
      Throws:
      IOException - if attempting to run a command in a specific directory
    • exec

      Process exec(CommandLine cmd, Map<String,String> env, File workingDir) throws IOException
      Launches the given command in a new process, in the given working directory.
      Parameters:
      cmd - The command to execute
      env - The environment for the new process. If null, the environment of the current process is used.
      workingDir - The directory to start the command in. If null, the current directory is used
      Returns:
      the newly created process
      Throws:
      IOException - if trying to change directory
    • isFailure

      boolean isFailure(int exitValue)
      Checks whether exitValue signals a failure on the current system (OS specific).

      Note that this method relies on the conventions of the OS, it will return false results if the application you are running doesn't follow these conventions. One notable exception is the Java VM provided by HP for OpenVMS - it will return 0 if successful (like on any other platform), but this signals a failure on OpenVMS. So if you execute a new Java VM on OpenVMS, you cannot trust this method.

      Parameters:
      exitValue - the exit value (return code) to be checked
      Returns:
      true if exitValue signals a failure