During the service hot swap mechanism development of NetServe I run into the problem that jar files getting locked by the JRE under Windows.
After some research I found a simple solution for this problem (maybe it’s a performance issue). Before you instanciate a custom classloader you have to disable caching on the URL.
URL[] urls = new URL[1]; urls[0] = new URL("/path/to/my.jar"); url.openConnection().setDefaultUseCaches(false); ClassLoader cl = new URLClassLoader(urls);
After that, your jar’s won’t get locked.