Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the relationship among JDK, JRE and JVM

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "what is the relationship between JDK, JRE and JVM". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and study and learn "what is the relationship between JDK, JRE and JVM" together.

JDK、JRE、JVM1. Java Platform Standard (JDK 8)

Oracle has two products that implement Java Platform Standard Edition (Java SE) 8: Java SE Development Kit (JDK) 8 and Java SE Runtime Environment (JRE) 8.

❞❝

JDK 8 is a superset of JRE 8, and contains everything that is in JRE 8, plus tools such as the compilers and debuggers necessary for developing applets and applications. JRE 8 provides the libraries, the Java Virtual Machine (JVM), and other components to run applets and applications written in the Java programming language. Note that the JRE includes components not required by the Java SE specification, including both standard and non-standard Java components.

❞❝

The following conceptual diagram illustrates the components of Oracle's Java SE products:

「Description of Java Conceptual Diagram」

Java Platform Standard Edition 8 Documentation

The relationship between JDK, JRE and JVM is clearly defined in the Java platform standard. That is the English introduction above.

Oracle has two Java platform standard products, Java SE Development Kit (JDK) and Java SE Runtime Environment (JRE). JDK(Java Development Kit), JDK is provided for Java developers to use, which contains java development tools, including JRE. So if you install JDK, you don't have to install JRE separately. Among them, the development tools include compilation tools (javac.exe), packaging tools (jar.exe) and so on. JRE(Java Runtime Environment) is a subset of JDK, which includes all the contents of JRE, as well as tools such as compilers and debuggers needed to develop applications. The JRE provides libraries, Java Virtual Machines (JVMs), and other components for running Java programming languages, Mini programs, and applications. JVM(Java Virtual Machine), JVM can be understood as a virtual computer, with the basic computing mode of the computer, it is mainly responsible for the Java program generated bytecode files, interpreted into specific system platform machine instructions, let it run on each platform.

In summary, from the platform standard introduction and concept diagram of this official website, it can be seen that the JVM we run the program has been installed in JDK, but you may have developed the code for a long time and have not noticed it. The biggest reason I haven't noticed is that I haven't developed any JVM-related component code.

"About", the platform standards of various JDK versions can be compared and studied by themselves, as follows:

Java SE 6 Documentation:https://docs.oracle.com/javase/6/docs/Java Platform Standard Edition 7 Documentation:https://docs.oracle.com/javase/7/docs/Java Platform Standard Edition 8 Documentation:https://docs.oracle.com/javase/8/docs/2. JDK directory structure and function

By default, after installing JDK, there will be two folders, jdk1.8.0_45 and jre1.8.0_45. In fact, there will also be JRE folders in JDK files, and the structure of their two JRE folders is the same.

JDK directory structure bin: a bunch of EXE executable files, java.exe, javac.exe, javadoc.exe, key management tools, etc. db: Built-in Derby database, small size, free installation. include: Java and JVM interaction header file, for example, we JVMTI write C++ projects, you need to include this include package into jvmti.h. For example: jre: Java runtime environment, including executable files required for runtime, Java class libraries and dynamic link libraries required for runtime.so .dll .dyliblib: Java class libraries, such as dt.jar, tools.jar

"Which folder is JVM in?"

jvm.dll

Maybe you haven't noticed jvm before: C:\Program Files\Java\jdk1.8.0_45\jre\bin\server

This part is the core content of the whole Java implementation across platforms. The.class file compiled from Java programs will be executed on the virtual machine. In addition, when the JVM interprets class files, it needs to call the class library lib. There are two folders lib and bin in the JRE directory, and lib is the class library required for JVM execution. jvm.dll doesn't work on its own; when jvm.dll starts, it uses the explicit method to load auxiliary DLLs and execute them together. 3. What is JDK?

Through Java platform standards and JDK directory structure, JDK is a superset of JRE, JDK contains all JRE development, debugging and monitoring application tools. And the following important components:

java -run tool, run.class bytecode javac-compiler, compile source code with suffix name.java into byte code with suffix name.class javap -decompiler javadoc -document generator, extract documents from source comments, comments should conform to specifications jar -package tool, package related class files into a file jdb - debugger, Debugging tools jps -Displays the process status of the current Java program running appletviewer -Tool to run and debug applets without using browser javah -Generates C header files and C source files from Java classes. These files provide bonding, allowing Java and C code to interact. javaws -Run JNLP program extcheck -A tool to detect jar package conflicts apt -Comment processing tool jhat - Java heap analysis tool jstack -Stack tracing program jstat - JVM detection statistics tool jstatd - jstat daemon jinfo -Get java program configuration information running or crashing jmap -Get java process memory mapping information idlj - IDL-to-Java compiler. Translate IDL language into java file policytool -a GUI policy file creation and management tool jrunscript -command line script run appletviewer: Mini programs browser, a Java browser that executes Java Mini programs on HTML files 4. What is JRE?

The JRE itself is also a program running on the CPU to interpret and execute Java code.

Generally, work like implementation installs JRE at the customer site because this is the minimum requirement to run Java programs.

JRE directory structure lib, binbin: java.exe but no javac.exe. That is, Java programs cannot be compiled, but Java programs can be run, and this bin directory can be understood as JVM. lib: Java Foundation & Core Library, contains libraries and rt.jar required for JVM runtime. It also contains files for security management, including security policies and security properties. 5. What is JVM?

In fact, simply speaking, JVM is a virtual machine running Java bytecode. JVM is a specification. Each vendor can implement its own JVM virtual machine. Just like Brother Fu himself, he also implemented the JVM virtual machine based on Java implementation according to the virtual machine specification and related books of handwritten JVM.

Java implementation JVM source code

Source Code Address: github.com/fuzhengwei/itstack-demo-jvm

This code mainly introduces how to implement the basic functions of JVM through java code (search and parse class files, bytecode commands, runtime data areas, etc.), so that java programmers can learn how JVM runs java programs step by step through the most familiar java programs.

"Of course," we downloaded Oracle's JVM compared to our own implementation, much more advanced. Their designs include continuously optimized memory models, GC reclamation strategies, adaptive optimizers, etc.

In addition, JVM is called virtual machine mainly because it implements "write-once-run-anywhere". It provides a runtime environment independent of the underlying operating system and machine hardware architecture.

5.1 Client mode, Server mode

There are two different startup modes in JVM: Client mode and Server mode.

Client mode: loading speed is faster. Can be used to run GUI interactive programs. Server mode: loads slower but runs faster. Can be used to run server daemons.

Modify the configuration mode file: C:\Program Files\Java\jre1.8.0_45\lib\amd64\jvm.cfg

# List of JVMs that can be used as an option to java, javac, etc.

# Order is important -- first in this list is the default JVM.

# NOTE that this both this file and its format are UNSUPPORTED and

# WILL GO AWAY in a future release.

#

# You may also select a JVM in an arbitrary location with the

# "-XXaltjvm=" option, but that too is unsupported

# and may not be available in a future release.

#

-server KNOWN

-client IGNORE

If you need to adjust, you can set client to KNOWN and adjust it to the front of server. JVM defaults to Server mode, -Xms128M, -Xmx1024MJVM defaults to Client mode, -Xms1M, -Xmx64M5.2 JVM structure and executors

This is the core knowledge of JVM, but it is not the focus of this article, and will be covered in subsequent chapters. This chapter is just an introduction.

Class Loader: A class loader is a subsystem used to load class files. Its main functions are loading, linking, and initialization. JVM Memory Areas: method area, heap area, stack area, program counter. Interpreter: By looking up predefined JVM instruction-to-machine instruction mappings, the JVM interpreter converts each bytecode instruction into its corresponding native instruction. It executes bytecode directly and does not perform any optimizations. JIT Compiler: To improve efficiency, the JIT Compiler interacts with the JVM at runtime and compiles bytecode sequences appropriately into native machine code. Typically, a JIT Compiler executes a piece of code, not one statement at a time. Optimize this code and translate it into optimized machine code. JIT Compiler is the default to open thank you for reading, the above is "JDK, JRE, JVM what is the relationship between" the content, after the study of this article, I believe that we have a deeper understanding of the relationship between JDK, JRE, JVM, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report