Java is how to achieve cross-platform, what is the principle?

Cross-platform, it refers to a program written in java language, after once compiled, can run on multiple platforms.

Cross-platform : Java program by java virtual machine running on the system platform, as long as the system can install the appropriate java virtual machine, the system can run java program. (noteNot be able to run on all platforms, the key is whether the platform can install the appropriate virtual machine).

Java cross-platform principle
by the source file (.java) -> byte code file (.class) (binary) -----> explain ----> Unix, Win, Linux and other machines.

1. once, run everywhere

2. The role of the compiler: the source file is compiled into class files

3. The role of the virtual machine: the interpreted byte code files to the corresponding platform and machine code execution.

4.java can be achieved across all platforms? Only provide and install a corresponding virtual machine that can be cross-platform.

5. The relationship between the virtual machine and interpreter: the interpreter is an important part of a virtual machine.

To perform 6.Java language compiled and interpreted in two phases.

Published 377 original articles · won praise 92 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_45743799/article/details/104632804