Java Basics 8-talking about the running mechanism of Java program and JVM running

Source: Internet
Author: User

First, the operation mechanism of Java program

The entire life cycle of Java development can be summed up in two phases: the compile phase and the run phase .

1. Compile Stage

① Programmers Write a Xx.java source file that conforms to the Java syntax.

② uses the Javac.exe command to compile the above Java source program.

③ generates a Xxx.class file if the compilation is passed.

2. Operation phase

① Open a Command window and run the Java program using the Java.exe command in the command window.

Second, Java Virtual machine run

As shown, the Java file Interpretation execution starts the JVM (the Java Virtual Machine) to run the program by dividing the memory area of the program into a binary file that can be recognized by the computer system.

Let's start with a picture of how the JVM works.

After compiling the class file, the JVM launches its ClassLoader to load the file, then the JVM divides the memory into 5 regions, and we currently only need to understand the main three areas

1. Method Area , also called data structure sharing area, the program will first go into this area

2. Stack memory , when the program executes, the main method first enters the bottom of the stack memory, then the code from the top down to execute the loading method, etc. will be stacked one by one, also known as compression stack.

3. Heap memory , loading instantiated objects executed in the stack memory, or some reference data types will open up a space in the heap memory and generate a 16-based address to the reference name.

Attached: The specific implementation will be in line with the specific procedures for detailed explanation.

Java Basics 8-talking about the running mechanism of Java program and JVM running

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.