This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic