The execution process of a Java program

Source: Internet
Author: User

We manually execute the Java program is this: 1, in Notepad or UE text Editor, write the source program, 2, using the Javac command to compile the source program into a. class file, the compiled. Class bytecode file contains the following: Constantpool: Symbol table; FieldInfo: member variable information in class, MethodInfo: Method description in class, Attribute: Optional additional node. The FieldInfo node contains the name of the member variable, such as flags such as public,private,static. The Constantvalue property is used to store the static value of the invariant member variable. Deprecated and synthetic are used to flag a member variable that is not recommended or generated by the compiler. 3 with the. class file, we can run the Java program by executing the Java Interpretation command. Now let's talk about what happens when you execute the Java command. First, the JVM loads the. class, which is the class loader that loads the class bytecode. A class loader itself is also a Java class, so,The class loader itself also needs to be loaded by another class loader, there is a problem like having an egg first, or having a chicken first. But the problem with the class loader in Java is easy to solve.
In a Java Virtual machine (JVM) embedded in a loader called the Bootstrap class, it is used in a specific Local code implementation of the operating system, which belongs to the Java Virtual Machine kernel, the bootstrap class does not load with a dedicated class loader. The Bootstrap class is responsible for loading the classes in the Java core package (that is, the classes in the Rt.jar file), class of those classes. getClassLoaderThe () method returns a value of NULL, which means the Bootstrap class loader.
There are two other class loaders in the Java Core package: Extclassloader and Appclassloader, which are written in the Java language Java class, where
The Extclassloader class load is responsible for loading the classes stored in the jar package in the <java_home>/jre/lib/ext directory,
Appclassloader is responsible for loading the application's startup execution class, which is the Java virtual machine that uses Appclassloader to load the class when the Java command is used to start executing a class.

When compiling and running a JAVA program, the Extclassloader class loader goes through the jar package in the <java_home>/jre/lib/ext directory to search for the class to be loaded, so if it will include the servlet The API's jar package or the Javamail.jar package is copied to the directory, and when you compile the servlet or JavaMail program, you do not have to add the jar package or the Javamail.jar package file that contains the Servlet API in the CLASSPATH environment variable. Above, is a Java program implementation of the approximate process. http://blog.csdn.net/jjeggplant4000/article/details/2130300

The execution process of a Java program (GO)

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.