Understanding of java virtual machine and compiler
java
Two levels of
For what everyone said java
, there are two levels of meaning. One is java
as a programming language , on the other hand as a runtime environment of java
.
java
-> Byte Code -> Native Code
Like other compiled languages, the source code java
of the java
syntax description is compiled and run .
However, what is generated after compilation is not the native code used by the cpu (explained after the paragraph), but the program called byte code , .class
file
-
Programs in machine language become native codes.
-
The programmer writes the source code.
-
By compiling the source code, you can get the native code.
-
Generally, what is included in the application software package is not the source code but the local code, that is, the compiled code.
To run byte code programs, we must create an environment for it . We call this environment a java virtual machine .
java
The virtual machine java
runs while converting byte codes into native codes one by one.
Compiler -> Virtual Machine -> CPU
The compiler converts the source code written by the programmer .java
into byte code, and the java
virtual machine converts the byte code into the native code used by the x86 series cpu , and then the x86 series cpu is responsible for the actual processing.
The said virtual machine is explained on the Wiki: a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment.
Each virtual machine has an independent CMOS, hard disk and operating system , and can operate the virtual machine just like a physical machine.
In simple knowledge, using virtual machines, we can run windows applications on the mac operating system. For example, VirtualBox for mac is an open source virtual machine software that can be used to run Windows software on the Mac OS platform.
java
virtual machine
From the operating system perspective, the java
virtual machine is an application; from the java
application perspective, the java
virtual machine is the operating environment.
Different operating systems will have different dedicated java
virtual machines. It's like the apps under the mac system and the apps under the Android system are not necessarily compatible.