myth

JVMS are not cross-platform, JAVA depends on JVMS, so JAVA should not be cross-platform

explain

Understand what cross-platform means: it does not depend on the operating system or hardware environment.

Different systems have different JVMS (JVMS are written in C), so JVMS are not cross-platform.

JAVA depends on the JVM, which provides the environment for JAVA to run, so JAVA is cross-platform.

To reinterpret that sentence… Be suddenly enlightened

Implementation process

The Java compiler compiles Java source programs into platform-independent bytecode files (class files), which are then interpreted and executed by the Java Virtual Machine (JVM). This bytecode is platform-independent and is a state between source code and machine instructions. In subsequent execution, an interpretation mechanism is adopted to interpret Java bytecode into machine instructions corresponding to the system platform. This not only reduces the compile times, but also enhances the portability of the program, so it is called “compile once, run many places!” .