title: Can a loaded JAR be deleted by the Java-Process?
body: <p>Hello I have following Problem:</p>
  
  <p>Within an uninstall-process I load a JAR (jdbc-driver). </p>
  
  <pre><code>    URL pDriverJar = jarToDelete.toURI().toURL();
      URL[] lURLList = new URL[]{pDriverJar};
      URLClassLoader lLoader =  new URLClassLoader(lURLList, Thread.currentThread().getContextClassLoader());
      Thread.currentThread().setContextClassLoader(lLoader);
      Class&lt;?&gt; aClass = Class.forName("jdbc.Driver"); // was Oracle: oracle.jdbc.OracleDriver but should not be important
  
      if(jarToDelete.delete()){
          System.out.println("deleted");
      }else {
          jarToDelete.deleteOnExit();
      }
  </code></pre>
  
  <p>After terminiation of the JVM, the jar is still existant.</p>
  
  <p>As a workarround, I've created a tempfile, and copied the Jar to that tempfile. But now the Tempfile will not be deleted.</p>
  
  <p>I've read, that if the ClassLoad is GC, the loaded jars can be removed.</p>
  
  <p>Does anyone have an Idea, how to delete this File?</p>