title: Deleting a directory on exit in Java
body: <p>I was just wondering if it was possible to delete a directory when the application was closed?</p>
  
  <p>Is there an easy way to do something when the application is closed?</p>
  
  <p>Currently my app downloads the class files at runtime so what I'm really looking for is something to remove them from the clients system.</p>
  
  <p>I've tried so far</p>
  
  <pre><code>File directory = new File("macros/bin/");
  directory.deleteOnExit();
  </code></pre>
  
  <p>As well as a delete on runtime of the downloaded startup files (which obviously can't be done seeing as it needs them in order to run).</p>