Loading Java classes from a signed applet

I think classes are lazy loaded in applets. being loaded on demand.

Anyway, if the classes are outside of a jar you can simply use the applet classloader and load them by name. Ex:

ClassLoader loader = this.getClass().getClassLoader();
Class clazz = loader.loadClass("acme.AppletAddon");

If you want to load classes from a jar I think you will need to create a new instance of URLClassLoader with the url(s) of the jar(s).

URL[] urls = new URL[]{new URL("http://localhost:8080/addon.jar")};
URLClassLoader loader = URLClassLoader.newInstance(urls,this.getClass().getClassLoader());
Class clazz = loader.loadClass("acme.AppletAddon");

By default, applets are forbidden to create new classloaders. But if you sign your applet and include permission to create new classloaders you can do it.


Yes, you can open URL connections to the host you ran your applet from. You can either create a classloader with HTTP urls, or download the classes (as jars) to the user's machine and create a classloader with those jars in the classpath. The applet won't stop and you don't need to load another page.

Regarding the second part of your question about confidence, once the user has granted access to your applet it can download anything, yes anything, it wants to the local machine. You can probably inform the user as to what it's doing, if your UI design permits this.

Hope this helps.