title: Elegant way to check whether external long-term jar launched successfully
body: <p>I am trying to execute external jar from java app. </p>
  
  <p><strong>What is the most elegant way to check if the process has been started successfully and running?</strong></p>
  
  <p>ExtApp.jar is long-term running process, so I can not use <code>Process.waiFor()</code> because it would block my app. I have come up with following code, with idea behind is that the <code>exitValue()</code> throws <code>IllegalThreadStateException</code> if the process has not been yet terminated.</p>
  
  <pre><code>boolean success = false;
  try {
      Process process = Runtime.getRuntime().exec("java -jar ExtApp.jar");
      try {
          if (process.exitValue() == 0) 
              success = true;
      } catch (IllegalThreadStateException e) {
          success = true;
      }
  } catch (Exception e) {}
  
  System.out.println(success);
  </code></pre>
  
  <p>But it is kind of ugly solution. Any ideas for a better one?</p>