The Java ClassLoader is a an abstract class which extends the Object class. Java class loader is a part of the Java Runtime Environment that dynamically loads Java classes into the Java Virtual Machine. Generally Java virtual machine load the classes only on demand. It is not necessary for Java run time system to know about files and file systems because of class loaders. Delegation provides a concept to understand when learning about class loaders.
Libraries in java are usually packaged in Jar files. A software library is a collection of more or less related object code. Libraries may include different sorts of objects, while Java class is the most popular type of objects contained in a Jar file. A class can be supposed as a unit of code having a name. The class loader locates libraries, reads their contents, and loads the classes contained within the libraries. Loading does not occur until the program uses the class bcoz loading is done on demand. A classloader loads only once to a class with a given name.
A class loader should locate or generate data constituting a definition for the class. A usual strategy performs transformation of the name into a file name and then reads a file of that name from the file system. Class loader does not create class object for array classes, but they are automatically created since required by the Java runtime. For primitive type elements array class has no class loader. Subclasses of ClassLoader class are implemented by the applications so that the Java virtual machine can dynamically load classes.
Posted on: June 19, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles