Interface CommandLauncher

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      java.lang.Process exec​(CommandLine commandLine, java.util.Map<java.lang.String,​java.lang.String> env)
      Executes the given command in a new process.
      java.lang.Process exec​(CommandLine commandLine, java.util.Map<java.lang.String,​java.lang.String> env, java.io.File workingDirectory)
      Executes the given command in a new process, in the given working directory.
      default java.lang.Process exec​(CommandLine commandLine, java.util.Map<java.lang.String,​java.lang.String> env, java.nio.file.Path workingDirectory)
      Executes the given command in a new process, in the given working directory.
      boolean isFailure​(int exitValue)
      Tests whether exitValue signals a failure on the current system (OS specific).
    • Method Detail

      • exec

        java.lang.Process exec​(CommandLine commandLine,
                               java.util.Map<java.lang.String,​java.lang.String> env)
                        throws java.io.IOException
        Executes the given command in a new process.
        Parameters:
        commandLine - 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:
        java.io.IOException - if attempting to run a command in a specific directory.
      • exec

        java.lang.Process exec​(CommandLine commandLine,
                               java.util.Map<java.lang.String,​java.lang.String> env,
                               java.io.File workingDirectory)
                        throws java.io.IOException
        Executes the given command in a new process, in the given working directory.
        Parameters:
        commandLine - The command to execute.
        env - The environment for the new process. If null, the environment of the current process is used.
        workingDirectory - The directory to start the command in. If null, the current directory is used.
        Returns:
        the newly created process.
        Throws:
        java.io.IOException - if trying to change directory.
      • exec

        default java.lang.Process exec​(CommandLine commandLine,
                                       java.util.Map<java.lang.String,​java.lang.String> env,
                                       java.nio.file.Path workingDirectory)
                                throws java.io.IOException
        Executes the given command in a new process, in the given working directory.
        Parameters:
        commandLine - The command to execute.
        env - The environment for the new process. If null, the environment of the current process is used.
        workingDirectory - The directory to start the command in. If null, the current directory is used.
        Returns:
        the newly created process.
        Throws:
        java.io.IOException - if trying to change directory.
        Since:
        1.5.0
      • isFailure

        boolean isFailure​(int exitValue)
        Tests 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.