[JAVA] Bytecode and virtual machine

Bytecode and virtual machine

Programs for PCs such as Windows and macOS do not work on supercomputers

Because the instructions (machine language) that the CPU can understand are different between the personal computer and the supercomputer. However, programs developed in Java work on PCs and supercomputers in the same way.

This is because the bytecode output from the Java compiler is a general machine language that does not depend on a specific CPU.

When running on a supercomputer to the machine language for Windows, it is converted to the machine language for the supercomputer.

In the PC or supercomputer
"Computer that understands mediocre machine language" appears to be executing bytecode

This is the origin of the name "Java Virtual Machine (JVM)"

Supercomputer

It can perform large-scale and advanced scientific and technological calculations that are difficult to solve with a general computer at high speed, and is mainly used in research institutes and companies.

A high-performance computer that can process calculations hundreds of thousands of times faster than a personal computer.

Bytecode

Binary data as an executable program used for Java virtual machines Classified as intermediate code, not machine language

Understand in the flow of development

compile
-The source code cannot be executed as it is
-Performs a process called compilation and converts the source file into a class file ".class」
-Bytecode, which is a conversion of each instruction in the source code so that it can be easily executed by a computer, is packed inside.
-If there is an error in the compilation using software called a compiler, the compilation will fail and the part of the error will be pointed out.

Run
-Bytecode is more suitable for execution than source code, but cannot be executed
-Request bytecode conversion execution to software called an interpreter
-The interrupter has a mechanism called JVM inside, and as a result, the computer operates as supported by the source code.

Recommended Posts

Bytecode and virtual machine
Setting up the CentOS 8KVM hypervisor and CentOS virtual machine
What is JVM (Java Virtual Machine)?