|
The Java Classloader is a part of the Java Runtime Environment that dynamically loads Java classes into the Java Virtual Machine[1]. Usually classes are only loaded on demand. The Java run time system does not need to know about files and file systems because of class loaders. Delegation is an important concept to understand when learning about class loaders. A software library is a collection of more or less related object code. In the Java language, libraries are typically packaged in Jar files. Libraries can contain various different sorts of objects, the most important type of object contained in a Jar file is a Java class. A class can be thought of as a named unit of code. The class loader is responsible for locating libraries, reading their contents, and loading the classes contained within the libraries. This loading is typically done "on demand", in that it does not occur until the class is actually used by the program. A class with a given name can only be loaded once by a given classloader.
Class loading processThe classloading process is fairly complicated, and is the subject of much confusion in software deployment and development. Java programs may make use of external or third party libraries (that is, libraries written and provided by someone other than the author of the program) or may itself be composed, at least in part, by a number of libraries. Each Java class must be loaded by a class loader. When the JVM is started, three class loaders are used[2] [3]:
The bootstrap class loader loads the core Java libraries, i.e. core.jar, server.jar etc. in the <JAVA_HOME>/lib directory. This class loader, which is part of the core JVM, is written in native code. The extensions class loader loads the code in the extensions directories (<JAVA_HOME>/lib/ext or any other directory specified by the java.ext.dirs system property). It is implemented by the sun.misc.Launcher$ExtClassLoader class. The system class loader loads code found on java.class.path, which maps to the system CLASSPATH variable. This is implemented by the sun.misc.Launcher$AppClassLoader class. User-defined class loadersBy default, all user classes are loaded by the default system class loader, but it is possible to replace it by a user-defined This makes it possible (for example):
Class Loaders in J2EEJ2EE application servers typically load classes from a deployed EAR archive by a tree of Classloaders, isolating the application from other applications, but sharing classes between deployed modules. So-called "servlet containers" are typically implemented in terms of multiple classloaders[5][6] JAR hellJAR hell is a term similar to DLL hell used[citation needed] to describe all the various ways in which the classloading process can end up not working.
To remedy the JAR hell problems a Java Community Process - JCP 277 has been initiated. The resolution - Java Module System - intends to introduce a new distribution format, modules versioning scheme and a common modules repository (similar in purpose to Microsoft .NET's Global Assembly Cache). See also
References
External links
|
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net