title: Java keeps waiting for getRuntime().exec
body: <p>I am building some kind of an updater function in my program. When an update is detected, the program should download an <code>updater.jar</code> and terminate. After that, the <code>updater.jar</code> will download a new version of the program and delete the old one. This is how my main program runs the updater:</p>
  
  <pre><code>Runtime.getRuntime().exec("java.exe -jar updater.jar "+updateURL+" "+workingPath);
  System.exit(0);
  </code></pre>
  
  <p>However, for some reason, the <code>System.exit(0)</code> doesn't get called until the updater is done... and the updater can't remove the old version of the main program while it's running. Result: <em>everything starts hanging</em>.</p>
  
  <p>Anyone got an idea how to tell my main program /not/ to wait for the updater to terminate before calling <code>System.exit(0)</code>?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>FileUtils.copyURLToFile(url, file);
  System.out.println("Downloading updater...");
  new Thread() {
      public void run() {
          try {
              Runtime.getRuntime().exec("java.exe -jar updater.jar "+updateURL+" "+workingPath);
          } catch (IOException ex) {
              System.out.println("Exception: " + ex.getMessage());
          }
      }
  }.start();
  System.out.println("Shutting down application.");
  System.exit(0);
  </code></pre>
  
  <p>Cmd displays the <code>"Shutting down application."</code>, but the <code>jar</code> doesn't seem to be shutting down until I manually kill the process.</p>