javarevisited

javarevisited


How ClassLoader Works in Java

Posted: 08 Dec 2012 03:55 AM PST

ClassLoader in Java works on three principle: delegation, visibility and Uniqueness. Delegation principle forward request of class loading to Parent class loader and only loads the class if parent is not able to locate or load class. Visibility principles allows Child ClassLoader to see all the classes loaded by Parent ClassLoader but parent ClassLoader can not see classes loaded by child ClassLoader. Uniqueness principle allows to load a class exactly once which is basically achieved by delegation and ensures that Child ClassLoader doesn't reload the class loaded by Parent ClassLoader. Correct understanding of ClassLoader is must to resolve issues like NoClassDefFoundError in Java and java.lang.ClassNotFoundException which are related to class loading. ClassLoader is also an important topic in advance Java Interview where good knowledge of working of class loader and How classpath works in Java  is expected from Java programmer. I have always see questions like Can one class be loaded by two different ClassLoader in Java on various Java Interviews.  In this ClassLoader tutorial we  will see What is ClassLoader in Java, How ClassLoader works in Java and some specifics about ClassLoader in Java.
Read more »


Post a Comment