Java class Loader load class order __java

Source: Internet
Author: User

The learning of Java ClassLoader

Java is a language that interprets execution. The Java source files written by developers are compiled into bytecode files. class form, then interpreted by the Java Virtual Machine (JVM), the. Class bytecode file itself is platform-independent, but the JVM is not, in order to achieve what is called a compilation, Everywhere, Sun provides the JVM implementations of each platform-that is, the JVM is not cross-platform, the compiled bytecode file is interpreted by the JVM on the different operating system platforms, and this chapter explains the mechanics of the JVM loading class.

What's 1.ClassLoader?

If a class is to be dispatched by the JVM, the class must first be loaded into the JVM memory, and there is a very important class classloader in the Java.lang, which is used to load classes of the specified name (under the specified path) into the JVM

Classification of 2.ClassLoader

Mainly divided into 4 categories, see the following Figure orange Section

JVM class Loader: This pattern loads the jar package under Java_home/lib

Extended class Loader: The jar package under Java_home/lib/ext is loaded

System class Loader: This is going to load the jar file specified with the Classpath parameter

User-defined class loader: Sun-provided classloader can be inherited, allowing the user to implement the ClassLoader themselves

The loading order of the ClassLoader is shown in the figure:

  

3. Class load Order

The JVM does not load all classes into the JVM all at once, and not every time you use a class to find it, the JVM class loader will load the default Java_home/lib class file into the JVM at startup, because these are common classes in the system, For other third party classes, then use to find, found on the cache, the next time you use this class can be directly used to cache the class object, ClassLoader is also a father-son relationship, not a ClassLoader have a father ClassLoader, The lookup order of ClassLoader with its parent ClassLoader when the class is loaded is shown in the following figure

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.