title: How to make a java program wait for external script to complete?
body: <p>I have run an octave script from Java using </p>
  
  <pre><code>ProcessBuilder pb = new ProcessBuilder("./ProcessImg");
  Process p = pb.start();
  </code></pre>
  
  <p>But after executing these statements, the program isn't waiting for the process to finish and comeback.</p>
  
  <p>How do I make the program wait for it? I want to use the file spit out by that script.</p>
  
  <p>Currently I am running the program twice, so that first time it creates the files and also an exception,the second time the program uses the previously created file.</p>