public int executeProcess(){
  final List<String> processStrings=tokenizeString(execCommand);
  processStrings.addAll(tokenizeString(script));
  logger.info(MessageFormat.format("Executing {0} ...",processStrings));
  final ProcessBuilder processBuilder=new ProcessBuilder(processStrings);
  if (workingDirectory != null) {
    final Path dir=Paths.get(workingDirectory);
    if (Files.notExists(dir)) {
      try {
        Files.createDirectories(dir);
      }
 catch (      IOException e) {
        logger.warning("Could not create working directory: " + workingDirectory);
        return -3;
      }
    }
 else     if (!Files.isDirectory(dir)) {
      logger.warning(workingDirectory + " already exists but is not a directory.");
      return -4;
    }
    final File directory=dir.toFile();
    processBuilder.directory(directory);
  }
  processBuilder.redirectErrorStream(true);
  Integer exitValue;
  try {
    logger.info("Starting external process ...");
    final Process process=processBuilder.start();
    sendInputStringToProcess(process);
    handleProcessOutput(process);
    try {
      exitValue=process.waitFor();
    }
 catch (    InterruptedException e) {
      logger.warning("Interrupted while waiting, killing external process ...");
      process.destroy();
      exitValue=-2;
    }
    logger.info("External process exit value " + exitValue + ".");
  }
 catch (  IOException e) {
    logger.log(SEVERE,"Failed to start external Process: ",e.getCause());
    exitValue=-1;
  }
  return exitValue;
}

public int executeProcess ( ) { final List < String > processStrings = tokenizeString ( execCommand ) ; processStrings . addAll ( tokenizeString ( script ) ) ; logger . info ( MessageFormat . format ( "Executing {0} ..." , processStrings ) ) ; final ProcessBuilder processBuilder = new ProcessBuilder ( processStrings ) ; if ( workingDirectory != null ) { final Path dir = Paths . get ( workingDirectory ) ; if ( Files . notExists ( dir ) ) { try { Files . createDirectories ( dir ) ; } catch ( IOException e ) { logger . warning ( "Could not create working directory: " + workingDirectory ) ; return - 3 ; } } else if ( ! Files . isDirectory ( dir ) ) { logger . warning ( workingDirectory + " already exists but is not a directory." ) ; return - 4 ; } final File directory = dir . toFile ( ) ; processBuilder . directory ( directory ) ; } processBuilder . redirectErrorStream ( true ) ; Integer exitValue ; try { logger . info ( "Starting external process ..." ) ; final Process process = processBuilder . start ( ) ; sendInputStringToProcess ( process ) ; handleProcessOutput ( process ) ; try { exitValue = process . waitFor ( ) ; } catch ( InterruptedException e ) { logger . warning ( "Interrupted while waiting, killing external process ..." ) ; process . destroy ( ) ; exitValue = - 2 ; } logger . info ( "External process exit value " + exitValue + "." ) ; } catch ( IOException e ) { logger . log ( SEVERE , "Failed to start external Process: " , e . getCause ( ) ) ; exitValue = - 1 ; } return exitValue ; }
executes the process specified by execcommand , classname , and optionally , invaluesstring .
