title: How to know if my ProcessBuilder start() executed the commands successfully
body: <p>I'm executing a command in java code using <code>ProcessBuilder</code> class. Once the <code>start()</code> is called I'm done with execution. Every time I run this code, I go to output and verify whether the java code has run the command successfully or not. Question is, will I be able to verify this in the code itself?, instead of verifying my output every time. In future I may not be able to view the output, so I want to make sure my commands run successfully or even if it runs into some exception, I should be able to know it from my code.</p>
  
  <p><code>start()</code> is returning me the <code>Process</code> class object and I hardly find any useful methods available under <code>Process</code> class.</p>
  
  <p>Code:</p>
  
  <pre><code>File file = new File(getClass().getClassLoader().getResource(fileName).getFile());
  
  List&lt;String&gt; list = new ArrayList&lt;String&gt;();
  list.add(my_command);
  
  String absPath = file.getAbsolutePath();
  list.add(absPath);
  ProcessBuilder pb = new ProcessBuilder(list);
  Process process = pb.start();
  List&lt;String&gt; commandList = pb.command();
  </code></pre>
  
  <p>Your help is very much appreciated!</p>
  
  <p><strong>Edit:</strong><br>
  Tried <code>process.exitValue();</code> but returning me the below error every time I execute my code. Point to note, my output is generated with out any issue even though I see this exception in my console.</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalThreadStateException: process has not exited
      at java.lang.ProcessImpl.exitValue(ProcessImpl.java:246)
      at com.rwithjava.caller.RWithJavaCaller.processRWithJavaScript(RWithJavaCaller.java:39)
      at com.rwithjava.caller.RWithJavaCaller.main(RWithJavaCaller.java:51)
  </code></pre>