code: public int run(
        List<String> command,
        @Nullable Path workingDirectory,
        @Nullable Map<String, String> environment,
        AsyncStreamHandler stdout,
        AsyncStreamHandler stderr)
        throws IOException, InterruptedException {
  
      logger.fine("Running command : " + command);
      if (workingDirectory != null) {
        logger.fine("In working directory : " + workingDirectory.toString());
      }
      if (environment != null && environment.size() > 0) {
        logger.fine("With environment : " + environment);
      }
  
      // Builds the command to execute.
      ProcessBuilder processBuilder = processBuilderFactory.createProcessBuilder();
      processBuilder.command(command);
      if (workingDirectory != null) {
        processBuilder.directory(workingDirectory.toFile());
      }
      if (environment != null) {
        processBuilder.environment().putAll(environment);
      }
      final Process process = processBuilder.start();
  
      stdout.handleStream(process.getInputStream());
      stderr.handleStream(process.getErrorStream());
  
      int exitCode;
      try {
        exitCode = process.waitFor();
      } catch (InterruptedException ex) {
        process.destroy();
        throw ex; // rethrow after cleanup
      }
  
      return exitCode;
    }
docs: Runs the command.
  
  @param command list of command line tokens
  @param workingDirectory the working directory to run the command from
  @param environment a map of environment variables
  @param stdout a stdout stream handler that must run on a separate thread
  @param stderr a stderr stream handler that must run on a separate thread
  @return exit code from the process