Java Virtual machines and cross-platform principles
Java Virtual Machine (JVM) is an imaginary computer that can run Java bytecode, and the cross-platform of Java is relative to other programming languages, use C programming and execution to compare Java programming and execution processes:
as with C, the Java source program is first written and then compiled by the Java compiler into the JVM executable code, Java bytecode, Java source The bytecode file generated after the compilation is equivalent to the EXE executable file on Windows compiled by the C source program, which is equivalent to the computer system (OS + hardware environment), an EXE file is running on Windows, and the JVM is running a Java bytecode file (. class file).
the process for Windows to execute an EXE executable file is to remove the computer instructions from the EXE file and give it to the CPU to interpret the execution. JVM executes Java bytecode process, and the JVM takes a byte code from the bytecode file to the CPU to execute. The CPU that executes the Java bytecode can be either hardware or is a software that runs on a system called the Java bytecode interpreter (that is, the JVM).
Summarize:
Interpreter = "CPU" of the JVM
The ①.exe file runs directly under the Windows operating system, which is the machine code that runs on the CPU.
The ②.class bytecode file is run under the JVM virtual machine, which is the Java bytecode that is running on the interpreter.
③ What is a program, the so-called Java compiler is the Java compiler (Javac.exe in the bin directory of the JDK), the Java interpreter is a specific platform under the interpreter (Java.exe in the bin directory of the JDK).
④ as long as the implementation of the specific platform of the interpreter, Java bytecode can be run through the interpreter program under the platform, which is the root of the Java cross-platform.
Java Virtual machines and cross-platform principles