java Compiler & Java Interpreter & JVM

Source: Internet
Author: User

transferred from:https://www.cnblogs.com/chengdabelief/p/6576320.html

JVM

The JVM has its own complete hardware architecture, such as processors, stacks, registers, and so on, as well as a corresponding instruction system (bytecode is an instruction format). The JVM masks information related to the operating system platform, making it possible for Java programs to generate only the target code (bytecode) that runs on a Java virtual machine, and to run unmodified on multiple platforms. The JVM is the basis of the Java platform independence. The JVM is responsible for running bytecode: The JVM gives each byte code to be executed to the interpreter, translates it into the corresponding machine code, and is then executed by the interpreter . The JVM explanation for executing bytecode files is the process by which the JVM operates the Java interpreter to interpret the execution of bytecode files .

Java compiler

Compile the Java source file (. java file) into a bytecode file (. class file, which is a special binary file, a binary bytecode file), which is the "machine language" of the JVM. Javac.exe can be simply seen as a Java compiler.

Java Interpreter

is part of the JVM. The Java interpreter is used to interpret the program that executes the Java compiler after compilation. Java.exe can be viewed simply as a Java interpreter.

Note: Typically, binary executables on one platform do not work on other platforms because this executable contains the machine language for the target processor. The class file is a special binary file that can be run on any hardware platform and operating system that supports Java virtual machines!

Wikipedia defines:

JVM: A virtual machine capable of running Java bytecode (Java bytecode).

Bytecode: Bytecode is compiled, but is not related to a specific machine code, it requires the interpreter to be translated into the machine Code Intermediate code.

Java bytecode: An instruction format that is executed by a Java virtual machine.

Interpreter: A computer program that can run a line of high-level programming languages directly. The interpreter does not translate the entire program at once, just like an "intermediary", and each time the program is run, it is turned into another language to run, so the interpreter's program runs slower. It runs as soon as it is translated into one line of the program, then translates the next line, then runs, so it keeps going. It will first translate the source code into another language for multiple runs without having to compile again. Its finished products do not rely on the compiler to run, the program runs faster.

Instant compilation (Just-in-time Compilation:jit): Also known as real-time compilation, timely compilation. Refers to a technique of compiling bytecode into native machine code at runtime, translating the source code one sentence at a time, but caching the translated code to reduce the loss of energy consumption. This technique is used to improve the performance of virtual machines.

The JIT compiler is part of the JRE. The original Java program has to be interpreted to execute, and its execution speed is certainly slower than the executable binary bytecode program. To improve execution speed, JIT is introduced. At run time, JIT will save the translated machine code for the next use. If the JIT compiles each bytecode, it will be overloaded, so the JIT compiles only the frequently executed bytecode, such as loops, the methods used for high frequencies, and so on. It compiles the entire method's bytecode into the local machine code at once, and then runs the compiled machine code directly.

Binary file: The generalized binary file is the file, which is named after the file is stored in the external storage device as a binary system. A narrow binary file refers to a file other than a text file. The format of the text file includes: ASCII, MIME, txt.

java Compiler & Java Interpreter & JVM

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.