title: Getting Output from the java process
body: <p>I am building a javaFx application I am running a command using java process builder class.</p>
  
  <pre><code>ProcessBuilder builder = new ProcessBuilder(runCommand);
  builder.redirectErrorStream(true);
  Process process = builder.start();
  try {
      process.waitFor();
  } catch (InterruptedException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>I am trying to get the output from the process I have tried two different ways but I am not able to get it.</p>
  
  <pre><code>InputStream stdout = process.getInputStream();
  InputStream stderr = process.getErrorStream ();
  BufferedReader reader = new BufferedReader (new InputStreamReader(stdout));
  String line1=null;
  while ((line1 = reader.readLine()) != null) {
      System.out.println(line1);
  }
  BufferedReader errorred = new BufferedReader (new InputStreamReader(stderr));
  while ((line1 = errorred.readLine()) != null) {
      System.out.println(line1);
  }
  </code></pre>
  
  <p>I tried also this:</p>
  
  <pre><code>ProcessBuilder builder = new ProcessBuilder(runCommand);
  //String outputLogs = new VerboseProcess(new ProcessBuilder(""));
  builder.redirectErrorStream(true);
  builder.redirectOutput(Redirect.INHERIT);
  builder.redirectError(Redirect.INHERIT);
  builder.redirectInput(Redirect.INHERIT);
  Process process = builder.start();
  try {
      process.waitFor();
  } catch (InterruptedException e) {
      e.printStackTrace();
  }
  </code></pre>