title: Webserver deployment issue
body: <p>My current project is writing a HTTP-Webserver in Java. The server checks a "deployment-directory" every two seconds and searches for a file named <code>content.jar</code>. If the file was changed the server deployes it. The file contains servlets which will be loaded by an <code>URLClassLoader</code>. On every deployment a new classloader is created.</p>
  
  <p>In a different project my servlets are being developed. I wrote an Ant-buildfile that creates the <code>content.jar</code> file and moves it into the server's deployment directory. Unfortunately I get an Ant error:</p>
  
  <blockquote>
    <p>BUILD FAILED  [path]\WebServerServlet\Ant\Build.xml:15: Unable to
    remove existing file [path]\WebServer\web\content.jar</p>
  </blockquote>
  
  <p>I suppose that the file is locked on the filesystem by the JVM - is there a way to tell Ant it should not try to delete and move the file but to overwrite it instead?</p>
  
  <p>Otherwise, does anyone have an idea how to avoid the file getting locked by the JVM by changing my deployment system?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I have now found a solution!
  As discussed in this <a href="https://stackoverflow.com/questions/11273303/java-classloader-dilemma-with-locked-jars">question</a> the only thing i had to add was</p>
  
  <pre><code>URLClassLoader loader = new URLClassLoader(..);
  //class loading stuff here
  loader.close() //the line all the trouble was about
  </code></pre>
  
  <p>With this appendix my Ant-buildfile is able to delete the "old" jar in the deployment-directory and move the new one into it.</p>