title: Run shell script from Java Synchronously
body: <p>I am trying to execute a Bash Shell script from Java and it runs fine using this piece of code.</p>
  
  <pre><code>public void executeScript() {
      try {
          new ProcessBuilder("myscript.sh").start();
          System.out.println("Script executed successfully");
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>The above code runs fine asynchronously. But what I would like to achieve is to execute the code synchronously. I would like the Java process to wait until the execution of the script is completed and then execute the next batch of code. </p>
  
  <p>To summarize, I would like the "Print statement - Script executed successfully" to be executed <strong>after</strong> the batch file ("myscript.sh") completes execution.</p>
  
  <p>Thanks</p>