Home  >  Article  >  Java  >  Why can java be cross-platform?

Why can java be cross-platform?

藏色散人
藏色散人Original
2019-05-22 10:20:1510861browse

Why can java be cross-platform?

Java is not only a programming language, but also a complete operating platform. The reason why Java can be cross-platform is inseparable from the JVM virtual machine.

JVM is a software. On different platforms, JVM has different versions. After Java is compiled, it will generate a .class file, which becomes a bytecode file. The JVM virtual machine translates Java compiled .class files into machine code for a specific platform and then runs it. In other words, after installing the JVM virtual machine corresponding to the platform on different platforms, we can convert the Java bytecode files and then run our Java program.

It is worth noting that the result of Java compilation is to generate bytecode, not machine code. Bytecode cannot be run directly and must be translated into machine code again through the JVM before it can be run. Even if a Java program is packaged into an executable file, it still requires the support of the JVM to run.

It is the Java program that is cross-platform, not the JVM. JVM is developed in C/C and cannot be platform-specific. The versions of JVM are different on different platforms.

Related learning recommendations: java basic tutorial

The above is the detailed content of Why can java be cross-platform?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn