aspose file tools*
The moose likes Java in General and the fly likes How to unload a class/jar from the classpath under Weblogic environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to unload a class/jar from the classpath under Weblogic environment" Watch "How to unload a class/jar from the classpath under Weblogic environment" New topic
Author

How to unload a class/jar from the classpath under Weblogic environment

Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
Hi guys,

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)?

Any help is appreciated.

Thanks!


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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
 
Don't get me started about those stupid light bulbs.
 
subject: How to unload a class/jar from the classpath under Weblogic environment