欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Java学习笔记-Class Loaders 博客分类: Java学习笔记 JavaEXTCC++C# 

程序员文章站 2024-03-01 20:08:22
...

 

 

A Java compiler converts source instructions for the Java virtual machine. The virtual machine code is stored in a class file with a .class extension. Each class file contains the definition and implementation code for one class or interface. These class files must be interpreted by a program that can translate the instruction set of the virtual machine into the machine language of the target machine.

 

The class loading mechanism doesn't just use a single class loader, however. Every Java program has at least three class loaders:

  • The bootstrap class loader

  • The extension class loader

  • The system class loader (also sometimes called the application class loader

The bootstrap class loader loads the system classes (typically, from the JAR file rt.jar ). It is an integral part of the virtual machine and is usually implemented in C. There is no ClassLoader object corresponding to the bootstrap class loader.

 

The extension class loader loads "standard extensions" from the jre /lib/ext directory. You can drop JAR files into that directory, and the extension class loader will find the classes in them, even without any class path.

 

The system class loader loads the application classes. It locates classes in the directories and JAR/ZIP files on the class path, as set by the CLASSPATH environment variable or the -classpath command-line option.

 

The Class Loader Hierarchy:
Java学习笔记-Class Loaders
            
    
    博客分类: Java学习笔记 JavaEXTCC++C# 

 

  • Java学习笔记-Class Loaders
            
    
    博客分类: Java学习笔记 JavaEXTCC++C# 
  • 大小: 120.3 KB