How can I make the JRE unload and then reload a class without restarting the application?

David Ben-Yaacov

In general, this is a very hard thing to do.

The first thing you should do is understand how Java handle loading and unloading of classes. Take a look at the Java Language Specification, version 2, Section 12.7 "Unloading of Classes and Interfaces".

The short answer is: Before you can load/unload a class you need to instantiate your own class loader. You can then load the class. When you want to unload the class, you also have to unload the class loader used to load your class. After you have unloaded your class loader you can load another class loader, and then reload your class.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact