Understanding of java virtual machine and compiler

Understanding of java virtual machine and compiler

javaTwo levels of

For what everyone said java, there are two levels of meaning. One is javaas 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 javaof the javasyntax 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 , .classfile

  • 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 .

javaThe virtual machine javaruns while converting byte codes into native codes one by one.

Compiler -> Virtual Machine -> CPU

The compiler converts the source code written by the programmer .javainto byte code, and the javavirtual 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.

javavirtual machine

From the operating system perspective, the javavirtual machine is an application; from the javaapplication perspective, the javavirtual machine is the operating environment.

Different operating systems will have different dedicated javavirtual machines. It's like the apps under the mac system and the apps under the Android system are not necessarily compatible.

Guess you like

Origin blog.csdn.net/weixin_43865875/article/details/108113863