What is a Java virtual machine? Why is Java called a "platform-agnostic programming language"?

Source: Internet
Author: User

Reply:

A Java Virtual machine is a virtual machine process that can execute Java bytecode. Java source files are compiled by the Javac compiler to generate bytecode files that can be executed by a Java virtual machine.

Java is designed to allow applications to run on any platform without requiring programmers to rewrite or recompile each platform individually. The so-called cross-platform is installed on different platforms different JVM, and on different platforms. class files are the same, and. class files are then interpreted by the corresponding platform JVM as the corresponding platform's machine code execution.

Analytical:

Java cross-platform is not a cross-platform of Java source programs, if so, so the language is cross-platform, The Java source program is compiled by the Javac compiler into binary. Class bytecode files (Java cross-platform refers to the. class bytecode file cross-platform,. Class bytecode files are platform-independent), the. class file runs on the JVM, and the Java Interpreter (part of the JVM) interpreted as the machine code execution of the corresponding platform, so what Java so-called cross-platform is to install different JVMs on different platforms, and the. class files generated on different platforms are the same, and the. class file is then interpreted by the corresponding platform JVM as the corresponding platform's machine code execution.

Finally, the difference between the machine code and the bytecode is explained:

One, machine code, fully attached to the hardware and exist, and different hardware due to the embedded instruction set is different, even if the same 0 1 code meaning may be different ~ in other words, there is no cross-platform-for example, different models of CPU, you give him a command 10001101, they may be resolved to different results.

Two, we know that Java is cross-platform, why? Because he has a JVM, no matter what kind of hardware, as long as you have the JVM, then he knew this Java bytecode. As for the bottom of the machine code, we do not have to tube, a JVM to do, he will translate the bytecode into the machine that the machine knows the code.

What is a Java virtual machine? Why is Java called a "platform-agnostic programming language"?

Related Article

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.