File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Programatically unloading a class ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Programatically unloading a class ..." Watch "Programatically unloading a class ..." New topic

Programatically unloading a class ...

Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585

Is there a way to unload my .class files rogramatically ???

I want to unload a class then reload it, i know how to load, but is there a way to unload then reload ???

Thanks in advance ...

Vassili ...
SCJP 5.0, SCWCD 1.4, SCJA 1.0
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
No, you can't unload a class.

If a class was loaded by a ClassLoader other than the main system class loader, the class will be garbage-collected along with the ClassLoader, when there are no more references to any classes from that ClassLoader.

While you cannot unload a class, you can load a new copy of the class, using a new ClassLoader. That's what people in your situation usually do. It is not trivial to get correct, however.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585
Thank you sir ...
I agree. Here's the link:
subject: Programatically unloading a class ...
jQuery in Action, 3rd edition