@Override
  public ProcessAdapter execute(File directory, String... commandLine) {

    Assert.isTrue(isDirectory(directory), "[%s] is not a valid directory", directory);

    Assert.notEmpty(commandLine, "The command-line %s must contain at least 1 command",
      Arrays.toString(commandLine));

    try {
      Environment environment = getEnvironment();

      ProcessBuilder processBuilder = newProcessBuilder(commandLine, directory, environment);

      Process process = doExecute(processBuilder);

      ProcessContext processContext = newProcessContext(process).from(processBuilder);

      return newProcessAdapter(process, processContext);
    }
    catch (IOException e) {
      throw new ProcessExecutionException(String.format("Failed to execute program %1$s in directory [%2$s]",
        Arrays.toString(commandLine), directory), e);
    }
  }
@ Override public ProcessAdapter execute ( File directory , String ... commandLine ) { Assert . isTrue ( isDirectory ( directory ) , "[%s] is not a valid directory" , directory ) ; Assert . notEmpty ( commandLine , "The command-line %s must contain at least 1 command" , Arrays . toString ( commandLine ) ) ; try { Environment environment = getEnvironment ( ) ; ProcessBuilder processBuilder = newProcessBuilder ( commandLine , directory , environment ) ; Process process = doExecute ( processBuilder ) ; ProcessContext processContext = newProcessContext ( process ) . from ( processBuilder ) ; return newProcessAdapter ( process , processContext ) ; } catch ( IOException e ) { throw new ProcessExecutionException ( String . format ( "Failed to execute program %1$s in directory [%2$s]" , Arrays . toString ( commandLine ) , directory ) , e ) ; } }
Uses the Java {@link ProcessBuilder} to execute the program defined by the given {@code commandLine}
in the given {@link File directory}.

@param directory {@link File directory} in which the program will run.
@param commandLine array of {@link String} values constituting the program and its runtime arguments.
@return a {@link Process} object representing the running program.
@throws IllegalArgumentException if the {@link File} reference is not a valid, existing directory
or the command-line is unspecified.
@throws ProcessExecutionException if the {@link Process} failed to start.
@see #newProcessBuilder(String[], File, Environment)
@see #doExecute(ProcessBuilder)
@see org.cp.elements.process.ProcessAdapter
@see org.cp.elements.process.ProcessContext
@see java.lang.Process
@see java.io.File