This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
One JVM. The number of classloaders depends on the app (or web) server. For Tomcat there is one classloader per web app. A parent class loader of the web app classloaders is "shared" by all web apps. Above that are "common", "system" and "bootstrap". An additional "catalina" classloader is a child of "common". The JVM has at least one additional classloader and more likely three. So if you have three webapps then you have at least 9 and probably more like 11 class loaders total. In Tomcat the ones you probably care about are the webapp specific classloader and the "shared" classloader (for shared libraries). If you are writing realms, connectors or resources then you may also touch "common" and "catalina".
Joined: Jul 04, 2004
But how to get hold of the "shared" classloader?? [ April 10, 2007: Message edited by: A Kumar ]
If you just need to load classes such that they are available to multiple webapps then put the classes/lib in the "shared" directory (i.e. C:\Program Files\Apache Software Foundation\Tomcat 5.5\shared on a Windows box with the default install). If you really need a reference to the shared class loader you can get a reference to the webapp class loader (this.getClass().getClassLoader() from a servlet will do the trick) and then get its parent (getParent()).