JDK, JVM, JRE in Java environment
Recently, I underestimated Android and came to my face with a bunch of concepts JDK, JVM, JRE, SDK, NDK, and ADT. After a little bit, JDK, JVM, and JRE are things in the java environment, while SDK, NDK, and ADT are things used in Android development. Let’s distinguish JDK, JVM, and JRE.
Tips: Where is it after mac installed on java? See the picture below
First, let's talk about JDK
JDK (Java Development Kit) is a software development toolkit (SDK) for the Java language.
JDK is the core of the entire JAVA, including the Java Runtime Environment, a bunch of Java tools (java/java/jdb, etc.), and Java basic class libraries (i.e. Java API).
There are three versions:
SE(J2SE), standard edition, standard edition, is a version we usually use. Starting from JDK 5.0, it is renamed Java SE.
EE(J2EE), enterprise edition, enterprise version, uses this JDK to develop J2EE applications, starting with JDK 5.0, and renamed to Java EE.
ME(J2ME), micro edition, is mainly used for Java applications on mobile devices and embedded devices. It has been renamed Java ME since JDK 5.0.
Let's talk about JRE
JRE is the abbreviation of Java Runtime Environment. Java Runtime Environment (including Java Plug-in) is Sun's product, which includes two parts: Java Runtime Environment and Java Plug-in. JavaRuntimeEnvironment (JRE) is a Java platform on which applications can be run, tested and transferred. It includes Java virtual machine (jvm), Java core class library and support files. It does not include development tools (JDK)-compilers, debuggers, and other tools. JRE requires auxiliary software -- Java Plug-in -- to run applets in the browser.
Without JDK, Java programs cannot be compiled, but programs can be run on systems with JRE environments. So when you just need to run a Java program or Applet, download and install JRE. If you want to develop Java software yourself, please download the JDK.
Finally, let’s learn about JVM
JVM is Java Virtual Machine (Java Virtual Machine). JVM is a specification for computing devices. It is a fictional computer that is implemented by emulating and simulating various computer functions on actual computers.
A very important feature of the Java language is its inconsistency with the platform. Using Java virtual machines is the key to achieving this feature. If a general high-level language is to run on different platforms, it needs to be compiled into different object codes. After introducing the Java language virtual machine, the Java language does not need to be recompiled when it runs on different platforms. The Java language uses the Java virtual machine to block information related to the specific platform, so that the Java language compiler can run without modification on multiple platforms by simply generating object code (byte code) running on the Java virtual machine. When a Java virtual machine executes bytecode, it interprets the bytecode as machine instructions on the specific platform. This is why Java can "compile and run everywhere".
This is a relationship diagram of the three:
The actual situation of our development is: after we develop our own JAVA program using JDK (called JAVA API), we compile our text java file into JAVA bytecode through the compiler (javac) in the JDK, run these JAVA bytecodes on the JRE, and the JVM parses these bytecodes and maps them to the CPU instruction set or OS system calls.
JVM (Java Virtual Machine), that is, Java Virtual Machine
The JVM blocks information related to the specific operating system platform, so that Java programs can run without modification on multiple platforms by simply generating object code (byte code) running on Java virtual machines. When JVM executes bytecode, it actually interprets the bytecode as machine instructions on the specific platform. The instruction set of a compiling a virtual machine is very similar to the instruction set of a compiling a microprocessor.
JVM is the basis of a cross-platform Java language (the "platform" here refers to different operating systems). To run Java programs on different operating systems, you need to install the corresponding JVM on different operating systems. Therefore, the JVM has Windows version, MAC version, Linux version, etc.
JRE (Java Runtime Environment), that is, Java running environment
JRE includes the core class libraries required by Java virtual machines and Java programs. If you want to run a developed Java program, you only need to install JRE on your computer.
Summary: JRE=JVM+Java class library
JDK (Java Development Kit), that is, Java Development Kit
JDK is provided for Java developers to use, including JRE and some Java development tools, such as compilation tools (javac.exe), packaging tools (jar.exe), etc. So after installing JDK, you don't need to install JRE anymore. As learners of the Java language, we must install JDK. Without JDK, we cannot compile and run Java code. This is also the reason why almost all Java introductory tutorials recommend us to install JDK.
Summary: JDK=JRE+Java development tools
Thank you for reading, I hope it can help you. Thank you for your support for this site!