An essential part of learning java ---JVM analysis (1)

One, the basic knowledge of JVM

1. How the program is executed

  • There are mainly the following three types: static compilation and execution, dynamic compilation and execution, and dynamic interpretation and execution

2. Why use JVM

解释
解释
机器码
机器码
java程序
java字节码
windows Java虚拟机
Linux Java虚拟机
windows操作系统
Linux操作系统
  • The difference between bytecode and machine code

    机器码是电脑CPU直接读取运行的机器指令,运行速度最快,但是比较难懂,也不好编写,一般人员接触不到
    字节码是一种中间状态(中间码)的二进制代码(文件)。需要直译器转译后才能成为机器码
    
  • The relationship between JDK, JRE and JVM
    JDK includes compilers and other development tools and JRE, JRE includes runtime library and JVM

  • The relationship between OracleJDK and OpenJDK

View the JDK version

java -version

(1) If it is SUN/OracleJDK, the displayed information is

java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

Description:
Java HotSpot(TM) 64-Bit Server VMIndicates that the JVM of this JDK is Oracle's 64-bit HotSpot virtual machine , running in Server mode (the virtual machine has two operating modes: Server and Client), which
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)is the version information of the java runtime environment (JRE)

(2) If it is OpenJDK, the display information is

[root@localhost ~]# java -version
openjdk version "1.8.0_144"
OpenJDK Runtime Environment (build 1.8.0_144-b01)
OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode)
  • OpenJDK
    (1) The origin of OpenJDK
    Java was invented by Sun Microsystems (Sun Microsystems, originated from Stanford University in the United States, SUN is the abbreviation of Stanford University Network). In 2006, Sun opened Java open source. At this time, JDK is OpenJDK
    . OpenJDK is an open source implementation of Java SE. It is supported by SUN and the Java community. In 2009, Oracle acquired Sun. Since then, SUN, one of the maintainers of Java, has also become Oracle.
    Most JDKs are based on OpenJDK. Written and implemented, such as IBM J9, Azul Zulu, Azul Zing and Oracle JDK. Almost all existing JDKs are derived from OpenJDK, and the difference between them is the license:

OpenJDK is released under the license GPL v2;
Oracle JDK is licensed under the Oracle Binary Code License Agreement.

(2) The origin of
Oracle JDK Oracle JDK was previously known as SUN JDK, which was named Oracle JDK after the acquisition before Oracle acquired SUN in 2009. In
fact, Oracle JDK is built based on the OpenJDK source code, so Oracle There is no major technical difference between JDK and OpenJDK.
The introduction of the relationship between the two by Joe Darcy, the project release manager of Oracle in OSCON 2011 also confirmed that OpenJDK 7 and OracleJDK 7 are very close in program, and the two share a lot of the same Note: The figure shows that the proportion of the common code of the two is much higher than the proportion seen on the graph, so the OpenJDK we compiled can basically be considered as the official performance, function and execution logic. The Oracle JDK is consistent.
(3) The difference between Oracle JDK and OpenJDK

OpenJDK is the open source free use of FreeType, can allow the use in commercial use in accordance with GPL v2 license V2 .GPL;
the Oracle is using the JDK JRL (Java Research License, Java Research License) released .JRL only allows the use of personal study,
to be To obtain the commercial license of Oracle JDK, you need to contact Oracle sales staff to purchase.

JRockit is Oracle's JVM. Starting with Java SE 7, HotSpot and JRockit are merged into one JVM.

  • What is the relationship between JVM and Hotspot?

JVM is the specification proposed in the "JVM Virtual Machine Specification".
Hotspot is a commercial product that uses the JVM specification. In addition, Oracle JRockit and IBM's J9 are also JVM products.
Insert picture description here

  • The difference between JVM client operating mode and server operating mode

JVM has two operating modes: Server and Client.
The difference between the two modes is that the Client mode starts faster, and the Server mode starts slower; but after the startup enters a stable period of long-term operation
, the server mode program runs much faster than the Client. This is because the JVM started in Server mode uses a heavyweight
virtual machine, which uses more optimizations on the program; while the JVM started in Client mode uses a lightweight virtual machine. Therefore, the server
starts slowly, but after it stabilizes, the speed is much faster than the client.

Guess you like

Origin blog.csdn.net/qq_44787898/article/details/109051162