title: Start Java program only if not already running
body: <p>I need to start 1-3 external programs in my Java application that have paths defined by the user.  I have few requirements:</p>
  
  <ol>
  <li><p>I don't want the program to execute if it is already running</p></li>
  <li><p>I don't want any of the programs to steal focus from my Java application</p></li>
  <li><p>I don't care if any of them fail to start or not.  They just need to fail silently.</p></li>
  </ol>
  
  <p>Here is what I have come up with so far:</p>
  
  <pre><code>ProcessBuilder pb = new ProcessBuilder(userDefinedPath1);
  try {
      pb.start();
  }
  catch (Exception e) {
      // Something went wrong, just ignore
  }
  </code></pre>
  
  <p>And then I repeat that 3 more times with the other two paths.  This starts like I would expect and meets my third requirement just fine, but fails on the first two.</p>
  
  <p>What is the best way to do this?</p>
  
  <p>Edit:</p>
  
  <ol>
  <li><p>I don't have any control of these other apps.  They are third party.  Also, they could have been start or stopped by the user manually at any time.</p></li>
  <li><p>I know the <em>exact</em> names of the executables (e.g. "blah.exe") and they will <em>always</em> be the same, but the paths to the executables won't necessarily be.</p></li>
  <li><p>Batch file wrappers are not feasible here.</p></li>
  <li><p>The other apps are <em>not</em> java apps, just plain old Windows executables.</p></li>
  </ol>