• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic