Home Java Javagetting Started The difference between jdk and jre

The difference between jdk and jre

May 25, 2020 pm 02:59 PM
jdk jre

The difference between jdk and jre

The difference between jdk and jre

1. Definition

JRE (Java Runtime Enviroment) It is the running environment of Java. For users of Java programs, not developers. If you only download and install the JRE, your system can only run Java programs. JRE is a collection of environments necessary to run Java programs, including JVM standard implementation and Java core class library. It includes Java virtual machine, Java platform core classes and supporting files. It does not contain development tools (compilers, debuggers, etc.).

JDK (Java Development Kit), also known as J2SDK (Java2 Software Development Kit), is a Java development tool kit. It provides a Java development environment (provides compiler javac and other tools for compiling java files for class files) and running environment (providing JVM and Runtime auxiliary packages for parsing class files to run them). If you download and install the JDK, you can not only develop Java programs, but also have a platform to run Java programs. JDK is the core of the entire Java, including the Java Runtime Environment (JRE), a bunch of Java tools tools.jar and the Java standard class library (rt.jar).

Recommendation: "java learning"

2. Difference

JRE mainly includes: the class file of the java class library ( All are packaged into jars in the lib directory) and virtual machines (jvm.dll); JDK mainly includes: class files of the java class library (all packaged into jars in the lib directory) and comes with a JRE. So why does the JDK come with a JRE? Moreover, the client and server folders under jdk/jre/bin both contain jvm.dll (indicating that the JRE that comes with JDK has two virtual machines).

Remember to set the jdk/bin path in the environment variable path? The teacher will tell everyone that javac and java cannot be used if they are not set up. It is true that the jdk/bin directory contains all commands. But has anyone ever thought that the java command we use is not in the jdk/bin directory but in the jre/bin directory? If you don’t believe me, you can do an experiment. You can cut the java.exe in the jdk/bin directory to another place and then run the java program. What did you find? Everything is OK! (There is no javac command in JRE, the reason is simple, it is not a development environment) So someone will ask? I obviously didn't set the jre/bin directory to the environment variable? Just imagine if java is for most people to use, they don't need jdk for development. They only need jre to make the java program run. Then how troublesome is it for each customer to manually set environment variables? So when you install jre, the installation program automatically adds jre's java.exe to the system variables for you. The verification method is very simple. Go to Windows/system32 and have a look. What did you find? There is a java.exe.

3. Difficulty

If JDK is installed, your computer will have two sets of JRE (JRE itself and the JRE in the JDK). The first set has less server-side Java than the latter set. virtual machine.

(1)Why does Sun require JDK to install two sets of the same JRE? This is because there are many development tools written in Java in the JDK (such as javac.exe, jar.exe, etc.), and they are all placed in /lib/tools.jar. If we rename tools.jar to tools1.jar and then run javac.exe, the following results will be displayed: Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/Main. This means that if you enter javac.exe and enter java -cp c:/jdk/lib/tools.jar com.sun.tools.javac.Main, you will get the same result. From here we can prove that javac.exe is just a wrapper (Wrapper), and the purpose of making it is to save developers from entering too long commands. And we can find that the programs in the /lib directory are very small, no larger than 29K. From here we can draw a conclusion. That is, almost all the tools in the JDK are written in Java, so they are also Java applications. Therefore, if you want to use the tools attached to the JDK to develop Java programs, you must also attach a set of JRE yourself, so the set located in the JDK directory JRE is used to run general Java programs.

(2) If more than two sets of JRE are installed on a computer, who will decide? This important task falls on java.exe. The job of java.exe is to find the appropriate JRE to run the Java program. java.exe searches for JRE in the following order: 1) Is there a JRE in its own directory; 2) Is there a JRE in the parent directory; 3) Query the registry: [HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java Runtime Environment]. Therefore, the running result of java.exe has a great relationship with which JRE is executed in your computer.

(3) There are two folders in the JDK-->JRE-->Bin directory: server and client. This is where the real jvm.dll is located. jvm.dll cannot work alone. When jvm.dll is started, it will use the explicit method (that is, using LoadLibrary() and GetProcAddress() in the Win32 API to load the auxiliary dynamic link library), and these auxiliary dynamic link libraries Dynamic link libraries (.dll) must be located in the parent directory of the directory where jvm.dll is located. Therefore, which JVM you want to use, you only need to set the PATH to point to jvm.dll in the directory where the JRE is located.

4. The most mainstream JDK is the JDK released by Sun. In addition to Sun, there are many companies and organizations that have developed their own JDK, such as JDK developed by IBM, Jrocket by BEA, and There are JDKs developed by the GNU organization and so on.

The above is the detailed content of The difference between jdk and jre. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run jar files in Linux How to run jar files in Linux Feb 20, 2024 am 10:40 AM

Prerequisites for running JAR files Running JAR files on a Linux system requires the installation of the Java Runtime Environment (JRE), which is the basic component required to execute Java applications, including the Java Virtual Machine (JVM), core class libraries, etc. Many mainstream Linux distributions, such as Ubuntu, Debian, Fedora, openSUSE, etc., provide software libraries of JRE packages to facilitate user installation. The following article will detail the steps to install JRE on popular distributions. After setting up the JRE, you can choose to use the command line terminal or the graphical user interface to start the JAR file according to your personal preference. Your choice may depend on familiarity with Linux shells and personal preference

How to install Java on Windows 11 How to install Java on Windows 11 Apr 13, 2023 pm 09:22 PM

Despite the large number of applications that appear every once in a while, Java remains by far one of the most used and important programming languages. Many applications rely on Java on Windows operating systems, and updating it means improving performance by providing stability and security for Java applications to run safely. You can also install Java on Linux and macOS platforms. The only difference is the package/file for each platform. Now, with Windows 11, it’s time to download Java and in today’s article, we will take you through the simple steps to install it on your device. Which version of Java should I download? The Java version you downloaded

Analysis of JDK dynamic proxy examples in java Analysis of JDK dynamic proxy examples in java Apr 30, 2023 pm 01:16 PM

1. Explain that Java provides a dynamic proxy class Proxy. Proxy is not the class of what we call proxy objects, but provides a static method (newProxyInstance) to create proxy objects to obtain proxy objects. 2. Instance publicclassHelloWorld{publicstaticvoidmain(String[]args){//Get the proxy object ProxyFactoryfactory=newProxyFactory();SellTicketsproxyObject=factory.getProxyObject();proxyO

Does oracle database require jdk? Does oracle database require jdk? Jun 05, 2023 pm 05:06 PM

The oracle database requires jdk. The reasons are: 1. When using specific software or functions, other software or libraries included in the JDK are required; 2. Java JDK needs to be installed to run Java programs in the Oracle database; 3. JDK provides Develop and compile Java application functions; 4. Meet Oracle's requirements for Java functions to help implement and implement specific functions.

Deepin Linux system installation JDK tutorial Deepin Linux system installation JDK tutorial Feb 15, 2024 pm 12:36 PM

Deepin Linux system is a domestic operating system based on the Linux kernel. It has the characteristics of stability, security, and ease of use. In Deepin Linux system, installing JDK (Java Development Kit) is a necessary step for developing Java applications. This article will introduce in detail how to Install JDK in Deepin Linux system. Installation steps: Open the terminal of Deepin Linux system. Use the command line to download the JDK installation package. The command is as follows: ``shellsudoapt-getinstallopenjdk-11-jdk`` Wait for the download to complete and the system will automatically install the JDK. To verify whether the JDK is installed successfully, enter the following command: ```javaj

Where is the linux jdk directory? Where is the linux jdk directory? Mar 22, 2023 am 09:52 AM

The linux jdk directory is in the bin directory. The specific search method is: 1. Find the execution directory of javad through the "whereis java" command; 2. Find the link file through the execution file; 3. Through "ls -lrt /etc/alternatives/java" Just run the command to find the installation directory.

How to install jdk-jdk installation tutorial How to install jdk-jdk installation tutorial Mar 04, 2024 pm 05:10 PM

Recently, many friends have asked me how to install jdk. Next, let us learn all about how to install jdk. I hope it can help everyone. 1. First download the JDK installation file and enter the JDK installation interface, as shown in the figure. 2. Click the "Next" button to enter the JDK custom installation interface, as shown in the figure. 3. It is recommended to choose to install directly to the default directory and click the "Next" button to install, as shown in the figure. You can also click the "Change" button to select the installation directory yourself. 4. After the installation is completed, the interface will pop up and click the "Close" button, as shown in the figure. The above is all the tutorials on how to install jdk brought by the editor. I hope it can be helpful to everyone.

How to configure the jdk environment in Linux system How to configure the jdk environment in Linux system May 12, 2023 am 09:31 AM

The following steps are to deploy the jdk environment in the Linux system 1. Download the jdk installation package 2. Create a new installation jdk folder (/usr/local/java/jdk) cd /usr/localmkdir/usr/local/javalocal directory and create a new java directory cd /usr/local/javamkdir/usr/local/java/jdk Create a new jdk directory cd/usr/local/java/jdk3. Upload the jdk installation package to linux4. Unzip the jdk installation package. Decompression format: The name after the tarzxvf compressed package name can be just Enter an initial letter and use the Tab key

See all articles