Search code examples
javajvmclassloader

why jvm has many clasloaders? why not one?


I am learning ClassLoader in Java, then I want to know, why JVM has many classloaders, why not only one? The one first load <Java_Runtime_Home>/lib, then load <Java_Runtime_Home>/lib/ext, and last load classpath.

If you have custom classloader, the system's first.

Somebody can tell me why JVM has many classloaders?


Solution

  • One very useful application is to be able to deploy several web applications into a single Java EE server.

    Each application might use different versions of the same libraries, and must thus have a different classloader from the others in order to be able to have different versions of the same classes in a single JVM.