title: java open file with default program
body: <p>I need to download a file from a java server using socket, and then open it with the default windows program. I've explored for several solution, but none fits perfectly for what I need. The aim is to temporarily open a file with an external default program and then delete the file when the external program exits. I've found these solution:</p>
  
  <ol>
  <li><code>Desktop.getDesktop.open(MyFile)</code>, but It seems it can't handle the returned value to check the external program exit</li>
  <li><code>ProcessBuilder</code>, it handles the external program exit, but It does not open the "default Windows program", and so I need to check every file extension to run the associated command. This solution is quite "close", but I can't know in advance all types of file to open</li>
  <li>Apache Commons Exec, that seems to be the same as 2, more reliable but with the same problem</li>
  </ol>
  
  <p>What to do?</p>