Content deleted Content added
m Removing link(s): Wikipedia:Articles for deletion/Java version history closed as delete (XFDcloser) |
fix some broken refs and extlinks |
||
Line 1:
The '''Java Class Loader''' is a part of the [[Java Runtime Environment]] that [[Dynamic loading|dynamically loads]] [[Java class]]es into the [[Java Virtual Machine]].<ref>{{cite web
|last1=Mcmanis |first1=Chuck
| title=The basics of Java class loaders▼
|url=https://www.infoworld.com/article/2077260/learn-java-the-basics-of-java-class-loaders.html
| publisher=[[JavaWorld]]▼
▲ | date=1996-10-01
A [[Library (computing)|software library]] is a collection of related [[object code]].
In the [[Java (programming language)|Java language]], libraries
Each Java class must be loaded by a class loader.<ref name="Christudas">{{cite web
|last1=Christudas |first1=Binildas
| url=http://www.onjava.com/pub/a/onjava/2005/01/26/classloading.html▼
| title=Internals of Java Class Loading▼
| publisher=onjava.com▼
|archiveurl=https://web.archive.org/web/20180510223447/http://www.onjava.com/pub/a/onjava/2005/01/26/classloading.html
▲ | date=2005-01-26
|archivedate=2018-05-10
| accessdate=2009-10-02 }}</ref> Furthermore, [[Java (software platform)|Java]] programs may make use of [[Library (computing)|external libraries]] (that is, libraries written and provided by someone other than the author of the program) or they may be composed, at least in part, of a number of libraries.▼
▲
When the JVM is started, three class loaders are used:<ref name="TJT:UECL">{{cite web
|
|
|department=The Java Tutorials
|work=docs.oracle.com
|
}}</ref><ref>{{cite web |last1=Sosnoski |first1=Dennis
| url=http://www.ibm.com/developerworks/java/library/j-dyn0429/▼
| title=Classes and class loading▼
|work=[[IBM DeveloperWorks]]
▲ | date=2003-04-29
|
}}</ref> # Bootstrap class loader
# Extensions class loader
# System class loader
The bootstrap class loader loads the core Java libraries<ref group=fn>These libraries are stored in [[JAR (file format)|Jar files]] called ''rt.jar'', ''core.jar'', ''server.jar'', etc.</ref> located in the <code><JAVA_HOME>/jre/lib</code> 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 (<code><JAVA_HOME>/jre/lib/ext</code>,<ref
by the <code>java.ext.dirs</code> system property). It is implemented by the <code>sun.misc.Launcher$ExtClassLoader</code> class.
Line 51 ⟶ 56:
** allowing multiple [[namespace]]s to communicate. This is one of the foundations of [[Common Object Request Broker Architecture|CORBA]] / [[Java remote method invocation|RMI]] protocols for example.
* to change the way the [[Java bytecode|bytecode]] is loaded (for example, it is possible to use [[Encryption|encrypted]] Java class bytecode<ref>{{cite web
|last1=Roubtsov |first1=Vladimir
| title=Cracking Java byte-code encryption▼
|url=https://www.infoworld.com/article/2077342/cracking-java-byte-code-encryption.html
|work=[[JavaWorld]]
▲ | date=2003-05-09
|
}}</ref>). * to modify the loaded bytecode (for example, for load-time [[
== Class Loaders in
[[
|last1=deBoer |first1=Tim
▲[[Java Platform, Enterprise Edition]] (Java EE) application servers typically load classes from a deployed [[WAR (Sun file format)|WAR]] or [[EAR (file format)|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.<ref name="Christudas"/><ref>{{cite web
|last2=Karasiuk |first2=Gary
| url=https://www.ibm.com/developerworks/websphere/library/techarticles/0112_deboer/deboer.html▼
|date=2002-08-21 |df=mdy
| title=J2EE Class Loading Demystified▼
|work=[[IBM DeveloperWorks]]
|
== {{anchor|jarhell}} JAR hell ==
JAR hell is a term similar to [[DLL hell]] used to describe all the various ways in which the classloading process can end up not working.<ref>https://web.archive.org/web/20130601002059/http://incubator.apache.org/depot/version/jar-hell.html</ref> Three ways JAR hell can occur are:▼
▲JAR hell is a term similar to [[DLL hell]] used to describe all the various ways in which the classloading process can end up not working.<ref>http://incubator.apache.org/depot/version/jar-hell.html</ref> Three ways JAR hell can occur are:
* Accidental presence of two different versions of a library installed on a system. This will not be considered an error by the system. Rather, the system will load classes from one or the other library. Adding the new library to the list of available libraries instead of replacing it may result in the application still behaving as though the old library is in use, which it may well be.
* Multiple libraries or applications require different versions of library '''foo'''. If versions of library '''foo''' use the same class names, there is no way to load the versions of library '''foo''' with the same classloader.
Line 81 ⟶ 85:
To remedy the JAR hell problems, a [[Java Community Process]] — JSR 277 was initiated in 2005. The resolution — [[Java Platform Module System]] — intended to introduce a new distribution format, a modules versioning scheme, and a common modules repository (similar in purpose to [[Microsoft .NET]]'s [[Global Assembly Cache]]). In December 2008, Sun announced that JSR 277 was put on hold.<ref>{{cite web
|
|
|
|
|
▲| accessdate=2015-11-29
▲| archive-url=https://web.archive.org/web/20151208171951/https://blogs.oracle.com/mr/entry/jigsaw
▲| archive-date=2015-12-08
▲| url-status=dead
}}</ref> The Java Module System was later rebooted as "project Jigsaw"<ref>{{cite web
|
|
|
|
}}</ref> which was included in Java 9. == See also ==
Line 103 ⟶ 107:
* [[Classpath (Java)]]
* [[Java Platform Module System]]
==Footnotes==
{{reflist|group=fn}}
==References==
{{reflist
== External links ==
* Chuck McManis, "[
* Brandon E. Taylor, "[http://www.developer.com/java/other/article.php/2248831 Java Class Loading: The Basics]", 2003
* Jeff Hanson, "[http://www.devx.com/Java/Article/31614 Take Control of Class Loading in Java]", 2006-06-01
* Andreas Schaefer, "[https://web.archive.org/web/20180506212821/http://www.onjava.com/pub/a/onjava/2003/11/12/classloader.html Inside Class Loaders]", 2003-11-12
* Sheng Liang and Gilad Bracha, "[
* Jeremy Whitlock, "[https://web.archive.org/web/20080628071703/http://dev2dev.bea.com/blog/jcscoobyrs/archive/2005/05/realworld_use_f.html Real-World Use For Custom ClassLoaders]", May 2005
* Dr. Christoph G. Jung, "[https://web.archive.org/web/20130201093532/http://www.roseindia.net/javatutorials/hotdeploy.shtml Classloaders Revisited Hotdeploy]", ''Java Specialist Newsletter'', 2001-06-07▼
▲* Jeremy Whitlock, "[http://dev2dev.bea.com/blog/jcscoobyrs/archive/2005/05/realworld_use_f.html Real-World Use For Custom ClassLoaders]", May 2005 -->
* Don Schwarz, "[https://web.archive.org/web/20180506083919/http://www.onjava.com/pub/a/onjava/2005/04/13/dependencies.html
▲* Dr. Christoph G. Jung, "[http://www.roseindia.net/javatutorials/hotdeploy.shtml Classloaders Revisited Hotdeploy]", ''Java Specialist Newsletter'', 2001-06-07
▲* Don Schwarz, "[http://www.onjava.com/pub/a/onjava/2005/04/13/dependencies.html?page=1 Managing Component Dependencies Using ClassLoaders]", 2005-04-13
[[Category:Java (programming language)]]
|