Why is JAVA popular
Different computer hardware and software environments on the Internet require a cross-platform language.
JAVA core advantage: Cross-platform
The JVM virtual machine
The JVM (JAVA VIRTUAL MACHINE) is a specification that can be implemented using either software or hardware; it is a VIRTUAL computer that executes Bytecodes. He also defines instruction sets, register sets, structural stacks, garbage collection heaps, and memory areas.
A JVM is a computer that is simulated by software or hardware on a computer, similar to a small and efficient CPU.
Java virtual machine is the core technology of Java and the foundation of cross-platform. You can use software, such as IBM, SUN, BEA, etc. Of course, you can also write a JVM, you can use hardware to implement, such as SUM/Intel is developing the Java chip
JVM and JAVA cross-platform features
The types of high-level computer programming languages are generally compiled and interpreted. The Java language is a combination of both types.
Compiled: First translate the entire English article into Chinese, and then read it.
Pros: Efficient reading.
Disadvantages: Need to wait for English teacher to translate English articles before reading.
The English teacher read us line by line advantage: there is no need to wait before reading
Disadvantages: Inefficient reading Common Java programs are written and executed in the following steps:
- Through the editor to write Java source program source file (source file name. Java).
- The compiler compiles the source program into a bytecode file (class name.class).
- Bytecode files are interpreted into the corresponding machine language by the interpreter and run (bytecode files are run in the JVM).
The above picture is a JAVA file compiled into a class file and the class bytecode file executed on different devices. VMS can be installed on different devices to achieve cross-platform and portable functions.
JAVA and C language cross-platform principle comparison
Java: Compile once, run anywhere
What the Java compiler does: Compiles, which compiles a source file into a bytecode file.
What the Java Virtual machine does: interpret, translate bytecode files into the machine language of the platform.
C: Compile multiple times, run everywhere