This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Dynamic class loading in an Applet from byte array.
Posted by Atif on June 20, 1999 at 11:33 PM
I have this peculiar problem. I want to load all the classes used
by the internet application written by us, in the JVM beforehand.
So once you login, it doesn't take time to download the classes.
The time taken is just to fetch the data from the database.
The problems we are facing are:
1. We are still using JDK1.1.6
2. I have put all the .class in a zip file and I am downloading
it at the runtime on the client machine, on a parallel thread.
Now I can get the byte arrays for the coressponding class files
I found that in ClassLoader class, there is a method defineClass(),
which converts a byte array into Class object.
Now I subclassed the ClassLoader class and implemented the loadClass()
method, since it is abstract in ClassLoader. I am able to get the Class
objects in this way, when I run this applet thru appletviewer, but I get
SecurityException on browsers. I think it's because of sandbox.
Since I can not use policy files in JDK1.1.x, is there any method
to overcome this problem.
Any help will be great.