How to unload a class/jar from the classpath under Weblogic environment
Joined: Apr 02, 2004
Did some search on the ranch & google & found that inorder for a class to be unloaded, its ClassLoader must be able to be garbage collected.
What I'm trying to do is to unload a class that is on my classpath. So I get class's ClassLoader, set it to null & invoke System.gc(). Tried to load the class (at a different location) but seems that the same old class is being loaded again.
So what exact codes/steps that I should have inorder to change my old Jar to a newer Jar (different location)?
You can't reliably make the JVM garbage collect an object, so I think this approach will have trouble. I looked at JUnit source code because the GUI runner tests new versions of classes without stopping and restarting. It just uses a new ClassLoader to load the new version. It might be customized to NOT call its parent loader first. It looks awfully simple but I haven't experimented to see how it works. See if that does what you need. Google for "java reload class" and find some other examples, too.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi