Click to See Complete Forum and Search --> : Class Loading
liuwayne
August 5th, 1999, 12:53 AM
Hi,
When I am running a Java app and instaniate the obj of class A, in the
middle of the process, I change the class A and re-compile. How can I make
the Java app to pick up the new class A without terminate and restart the
JVM?
thks, wayne
unicman
August 5th, 1999, 02:18 AM
I don't think there is any way for this. Actually I'm also looking for something like this.
But as far as my knowledge is concerned, jvm doesn't read the classes after loading them first time.
If u find some method for this, I will also be interested!
- UnicMan
http://members.tripod.com/unicman
varbsjava
August 5th, 1999, 03:03 AM
For this case, you have to write your own classloader which extends the ClassLoader class. In your classloader override the method loadClass(..).
In the loadClass(..) method, get the class name and read the contents of the class into a byte array by getting a inputstream for the class. After that use the defineClass(..) method to convert your byte array into a Class object and then use that class object to get the new instance.
I hope this will work but I haven't tried this.
regards,
arun...
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.