JDK,JRE,JVM
1. JDK
1 Overview
The abbreviation of Java Development Kit,
Java
the toolkit for development, is the core of the entire JAVA, including theJava
runtime environment (Java Runtime Environment), a bunch of Java tools (javac/java/jdb, etc.) and Java-based class libraries (ie, Java APIs). Including rt.jar), JDK=JRE+ development toolset (such as Javac compilation tools, etc.), provided by SUN. Every Java learner will first install a JDK on the machine, because it provides a compilation and running environment for Java program development , and all Java program writing depends on it. Using the JDK, Java programs can be written as bytecode files, ie .class files.
2. Subdirectory Description
There are six folders, a src class library source code package, and several other declaration files under the directory.
Among them, the important ones are the following four folders: bin, jre, include, lib .
⭕ bin : Development tools, including tools and utilities used to develop, execute, and debug Java programs, as well as class libraries and support files required for development tools, the most important being the compiler (javac.exe)
⭕ jre : The runtime environment, which implements the Java runtime environment. Is the environment necessary to run Java programs. JRE contains the Java Virtual Machine JavaTM Virtual Machine (JVM), Java core class library and supporting files.
If you are just running Java programs, you only need to install the JRE. If you want to develop a Java program, you need to install the JDK, and you do not need to install the JRE, because the JRE is already included in the JDK.
⭕ include : The header file for java and JVM interaction, which supports native code programming using the Java native interface and the Java virtual machine debugging interface. Since JDK is implemented by C and C++, some header files of C language need to be introduced at startup, so there are some header files for C language in the include directory. The header files of C language support Java native interface and Java virtual native programming techniques for the machine debugger interface.
⭕ lib : lib is an abbreviation for library (class library). Stored are archived package files used by development tools. For example, jar package, etc.,
Note: The bin and lib folders here are different from the bin and lib in jre
2. JRE
1 Overview
JRE
(Java Runtime Environment, Java Runtime Environment), includingJVM
standard implementation and Java core class library,JRE=JVM+JavaSE标准类库
. It is the running environment of Java, so to execute any Java program, it needs to be installed on the machineJRE
, which is the minimum requirement. But it's not a development environment, so it doesn't include any development tools (such as compilers and debuggers), in short, if you're a Java application developer writing code, you'll need to installJDK
it, if you just want to run Java builds Application, you only need to install itJRE
, itJDK
is used for the development of java programs, butJRE
it can only be run.class
without the function of compiling.
JRE
It can be downloaded asJDK
part of it or it can be downloaded separately,JRE
depending on the platform, which means that depending on the machine type (OS and architecture), the JRE package to import and install must be selected.
For example: you can't install 64-bit onJRE
a 32-bit machine, and similarly, distros for Windows won't work on Linux platforms.
3. JVM
1 Overview
JVM
(Java Virtual Machine) is a virtual machine that runs Java bytecode. It is a specification for computing devices. It is a fictional computer that is realized by simulating various computer functions on an actual computer.
It provides a runtime environment that can execute Java bytecodes, and obtain bytecode files by compiling java files into .class files . When the Java virtual machine executes the bytecode, it interprets the bytecode into machine instructions for execution on a specific platform. That's what makes Java "compile once, run anywhere".
Fourth, the connection and difference between JDK, JRE, and JVM
1. Contact
First of all, we have to understand how Java source files are executed?
(1) Use an editor or IDE (Integrated Development Environment) to write Java source files. ie
Simple.java
.
(2) Programs must be compiled into bytecode files, and javac (Java compiler) compiles source files intoSimple.class
files. (3) Class files can be executed by (Java virtual machine)
on any platform/operating system . (4) Translate the bytecode file into machine code (0,1 binary) that the machine can execute.JVM
JVM
⭕ That is, after we use
JDK
(callJAVA API
) to develop our own JAVA program, we compile our text file into bytecode throughJDK
the compiler ( ) in , run these bytecodes on , and parse these bytecodes, System calls that map to the CPU instruction set or OS.javac
java
JAVA
JRE
JAVA
JVM
⭕ The execution
JVM
cannot be done alone . When.class
interpreting.class
, youJVM
need to call the class library required for interpretationlib
. In theJDK
followingjre
directory, there are two foldersbin
andlib
, here it can be considered that thebin
inside is the class library required for the work, and the sum is called .JVM
lib
JVM
JVM
lib
JRE
2. Differences
JRE = JVM + libraries to run Java Application
JDK = JRE + tools to develop Java Application