Program running process:
1. First compile the Java code into bytecode, that is, compile the ".java" type file into ".class" type of file.
The approximate execution flow of this process: Java source code -> Lexical analyzer -> Syntax analyzer -> Semantic analyzer -> Bytecode generator ->Finally generate bytecode , the execution failure of any node will cause the compilation to fail;
2. Place the class file into the Java virtual machine. This virtual machine usually refers to Oracle’s official Hotspot JVM;
3. The Java virtual machine uses the class loader (Class Loader) to load the class file;
4. After the class loading is completed, bytecode verification will be performed. The bytecode verification will be processed by the JVM interpreter. The bytecode is translated into machine code and executed by the operating system, but not all codes are interpreted and executed, and the JVM has optimized this.
For example, take the Hotspot virtual machine, which itself provides JIT (Just In Time), which is what we usually call a dynamic compiler. It can compile hot code into machine code at runtime. This At that time, the bytecode becomes compiled and executed.
Recommended tutorial: java introductory tutorial
The above is the detailed content of How does a java program run?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 English version
Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.