Loading...

Monday, August 4, 2014

JAVA CLASSLOADER- Types, usages.

JVM loads library and classes dynamically only. Its on demand only.
A Class will be loaded only when needed and only once.

There can be system supported class loader and user supplied class loader.
When JVM starts it loads three type of class loader
1. Bootstrap loader - When system boots. Loads from jre_home/lib/
2. External class loader - Loads from jre_home/lib/ext.
3. System Class loader - Loads classes from system property CLASSPATH.


Besides this user can provide their own class loader which is pretty easy to implement in Java.
User supplied loader will work in conjunction with other loader i.e. system loader too.

Some of the examples are:

1. Load library at runtime from http resources. Example scripting classes, bean classes.
2. Can load encrypted class files with new class loader.
3. Modify the byte code.

Application Container loads classes from deployed WAR or EAR files using a tree of class loaders.

No comments:

Post a Comment