The difference between JRE and JDK

Source: Internet
Author: User

1. definition

JRE (Java Runtime enviroment) is the Java operating environment . For users of Java programs, not developers. If you download and install only the JRE, your system can only run Java programs. The JRE is the set of environments necessary to run a Java program, including the JVM standard implementation and the Java Core Class library. It includes Java virtual machines, Java platform core classes, and supporting files. It does not contain development tools (compilers, debuggers, etc.).

The JDK (Java Development Kit) , also known as J2SDK (JAVA2 Software Development Kit), is the Java SDK, which provides a Java development environment that provides tools such as compiler Javac Used to compile Java files into a class file) and the runtime environment (provides JVM and runtime helper packages for parsing class files to make it run). If you download and install the JDK, you can not only develop Java programs, but also have a platform to run Java programs. The JDK is the core of the entire Java, including the Java Runtime Environment (JRE), a stack of Java tools Tools.jar, and the Java Standard Class library (Rt.jar).

2. Differences

The JRE mainly consists of the Java Class Library's class file (both packaged in the Lib directory as a jar) and the virtual machine (jvm.dll); the JDK mainly contains: the Java Class Library's class file (all packaged in the Lib directory as a jar) and comes with a JRE. So why does the JDK bring a JRE? The client and server two folders under Jdk/jre/bin contain Jvm.dll (which shows that the JDK comes with two virtual machines).

Remember to set the Jdk/bin path in the environment variable path? The teacher will tell you not to set the words javac and Java can not be used. It is true that all commands are contained under the Jdk/bin directory. But has anyone thought that the Java commands we use are not in the Jdk/bin directory but in the Jre/bin directory? Do not believe you can do an experiment, you can put the Jdk/bin directory Java.exe cut to another place to run the Java program, found what? All ok! (There is no Javac command in the JRE, for the simple reason that it is not a development environment) then someone would ask? I did not set the Jre/bin directory into the environment variable ah? Imagine if Java in order to provide for the majority of users, they do not need to develop the JDK, only the JRE can let the Java program run up, then each customer also need to manually set the environment variable how much trouble ah? So install the JRE when the installation program automatically help you to add the JRE Java.exe to the system variables, the verification method is very simple, go to windows/system32 below to see it, find out what? There is a java.exe.

3. Difficulties

If you have a JDK installed, your computer will have two sets of JRE (JRE itself and JRE in the JDK), which is a smaller server-side Java Virtual machine than the one behind it.

(1) Why does Sun want to have the JDK install two identical JRE? This is because the JDK has a lot of Java-written development tools (such as Javac.exe, Jar.exe, etc.), and is placed in the/lib/tools.jar. If we rename Tools.jar to Tools1.jar and then run Javac.exe, the following result is displayed: Exception in thread "main" Java.lang.noclassdeffounderror:com/sun /tools/javac/main. This means that your input javac.exe is the same as the input JAVA-CP C:/jdk/lib/tools.jar Com.sun.tools.javac.Main, and will get the same result. From here we can prove that Javac.exe is just a wrapper (Wrapper), and the purpose of the production is to keep the developer from entering too long a finger. And can find the/lib directory of the program is very small, not more than 29K, from here we can draw a conclusion. Is that the JDK tool is almost written in Java, so it is also a Java application, so to use the tools attached to the JDK to develop Java programs, you must also have to attach a set of JRE, so in the JDK directory of the JRE is used to run generic Java programs.

(2) If a computer installs more than two sets of JRE, who will decide? The big task falls on Java.exe. Java.exe's job is to find the right JRE to run Java programs. Java.exe in the following order to find jre:1) in their own directory there is no jre;2) parent directory has no jre;3) query registry: [Hkey_local_machine/software/javasoft/java Runtime Environment]. So Java.exe's running results have a lot to do with which JRE in your computer is being executed.

(3) There are two folders under the Jdk-->jre-->bin directory: Server and client, which is where the real jvm.dll is. Jvm.dll cannot work alone, and when Jvm.dll is started, it uses the explicit method (that is, using LoadLibrary () and GetProcAddress () in the Win32 API to load the auxiliary dynamic-link library). These auxiliary dynamic link libraries (. dll) must be in the parent directory of the directory where the Jvm.dll resides. So which JVM you want to use, just set path and point to the Jvm.dll in the directory where the JRE resides.

4. The most mainstream JDK is the JDK released by Sun, and in addition to sun, many companies and organizations have developed their own JDK, such as the Jrocket of JDK,BEA company developed by IBM, the JDK developed by the GNU organization, and so on.

The difference between JRE and JDK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.