Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how I enforce class reload from class file.

Status
Not open for further replies.

goodgood

Programmer
Feb 15, 2001
13
IL
Hi All,
I want to enforce the reload of class file, and not to use the already loaded class from the classloader cache, how can I do it without rewrite the loadclass() of the classloader ?

thanks in advanced, Rami.
 
Hi Rami:

It depends on why you want to reload a class. Are you dealing with an applet? If it is the case, you could have some problems writing a new classloader in netscape, but if you have the plugin installed you can manage its properties to clear the classloader:

javaplugin.classloader.cache.enabled=true|false
javaplugin.classloader.cache.sizes=<n>

If you are dealing with an application you must write your own classloader. It is not as difficult as it sounds, check this url for more information on writing a classloader:


Try to use the default classloader if you doesn't want to rewrite the loadclass method.

Once you have it, you can load again your class with your custom classloader. Each new version of a class needs a new class loader. And of course anything that is using the old class has to discard those instances and get a new instance of the new version.

Feel free to postback if you have any other question.

Hope it helps.
Pedro Andrés Solorzano
Pontificia Universidad Javeriana
Bogotá, Colombia, SurAmérica.
 
I'm just curious as to when would someone want to rewrite a classloader? I've heard some discussion about it and I wonder why this is an issue. Could someone please explain this.

JavaDude32
 
Pedro Thanks,

JavaDude32 :
if you don't want to restart your application each time some class is changing (very usefull for developing stage).

regards goodgood
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top