JDK JRE Differences

Source: Internet
Author: User
Tags new set

The tools inside the JDK are also written in Java, which in itself requires a set of JRE, such as the JRE under the C:/Program files/java/jdk1.5.x/directory. The JRE in the C:/Program files/java/directory is used to execute the Java programs we write ourselves. Of course, either of the two sets of JRE can be used to execute our own Java programs, but the tools inside the JDK are only executed by the JRE in the C:/Program files/java/jdk1.5.x/directory.


Other words
The JDK (Java Development Kit) is the developer kit, which is equivalent to a compiler.
The JRE (Java Runtime Environment) is a running environment, equivalent to a JVM virtual machine. Java programs developed by the JDK must run in the JVM, and the JRE provides such an environment.
----------------------------------------------------------------------------

The JDK is Java development Kit. To put it simply, the JDK is a developer-oriented SDK that provides a Java development environment and a running environment. The SDK is software Development Kit generally refers to a software development package, which can include function libraries, compiler programs, and so on.

The JRE is Java runtime enviroment, which refers to the Java Runtime Environment, and is intended for users of Java programs, not developers.

If the JDK is installed, there will be two sets of JRE on your computer, one in the/jre and one in the C:/Program files/java/jre1.5.0_15 directory, and the other Java virtual machine, which is less server-side than the previous set. But just copy the server-side Java Virtual machine in front of you. You can also choose whether to install the JRE in the C:/Program Files/java directory when installing the JDK. If you install only the JRE, not the JDK, only a single set of JRE will be installed in the C:/Program Files/java directory.

The JRE is like a PC, and our WIN32 application requires the operating system to run it, and the Java program we write must also have the JRE to run. So when you're finished installing the JDK, if you have two sets of JRE installed in two different places on your hard drive, you can imagine your computer has two virtual Java PCs, all with the ability to run Java programs. So we can say that if you have a JRE installed on your computer, you can run Java applications correctly.

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. As can be seen from the following example, first renamed Tools.jar to Tools1.jar, and then run Javac.exe, showing the following result: 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 2 9K, from here we can draw a conclusion. Is that the tool in the JDK 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 attach a set of JRE, so it is located in C:/Program files/ The JRE in the Java directory is used to run generic Java programs.

2, if a computer installed 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 the JRE according to the following order: There is no JRE in its own directory; the parent directory has no JRE; 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.


ADD: (small summary)

The

1.JVM--Java Virtual machine
JVM is what we often call Java VMS, the most central part of the entire Java implementation across platforms, All Java programs are first compiled into a. class file, which can be executed on a virtual machine, which means that class does not correspond directly to the machine's operating system, but instead interacts with the operating system indirectly by the virtual machine, which interprets the program to the local system for execution. The
2.JRE--Java Runtime Environment
JRE refers to the Java Runtime environment. The JVM cannot be executed as a class, because the JVM needs to invoke the class library lib that is needed to interpret the classes. In the JDK installation directory you can find the JRE directory, there are two folders Bin and Lib, here you can think that the bin is Jvm,lib is the JVM to work the class library, and the JVM and Lib are called the JRE. So, after you've finished compiling the Java program into. class, you can package the. class file with the JRE and send it to your friends so that your friends can run your program. (The JRE is running. Class Java.exe)
3.JDK--Java Development Kit
JDK is the Java SDK, basically everyone who learns Java will first install a JDK on the machine, which part does he contain? Let's take a look at the JDK installation directory. Under the directory there are six folders, a SRC class library source code compression package, and several other declaration files. One of the four folders that really worked when running Java was the following: Bin, include, Lib, JRE. Now we can see a relationship where the JDK contains the JRE, and the JRE contains the JVM.
Bin: The main thing is compiler (Javac.exe)
Include:java and JVM interaction with the header file
Lib: Class library
Jre:java Run environment
(NOTE: Here the bin, Lib folder and the bin in the JRE , Lib is different) in general the JDK is used for Java program development, while the JRE is a function that can only run class without compiling.

Other Ides, such as Eclipse, idea, have their own compilers instead of their own in the JDK Bin directory, so at the time of installation you will find that they only require you to check the JRE path.

-----------------------------------------------------------

About JDK and JRE

It is certain that when installing the JDK there will be a choice of whether or not to install a separate JRE, which will generally be installed together, and I recommend that you do so. Because it will help you figure out the difference:

The Jre is the Java Runtime Environment, which is the operating environment of the Java program. Since it is running, of course, to include the JVM, which is familiar with the virtual machine, as well as all the Java library class files, are packaged in the Lib directory into a jar. You can verify it yourself. As to which file is the virtual machine on Windows? Learn MFC all know what is DLL file, then we look at jre/bin/client inside there is not a jvm.dll it? That's the virtual machine.

The JDK is Java Development Kit, a Java SDK that contains a variety of class libraries and tools. And, of course, another JRE. So why do we include another JRE? Also, Jdk/jre/bin has both client and server two folders that contain a jvm.dll. Description is available for two virtual machines. Do we not know if we have noticed this point?

We all know that the JDK under the bin has a variety of Java programs need to use the command, and the JRE Bin directory is the most obvious difference is the JDK under the Javac, this is very well understood, because the JRE is only a running environment. It is not related to development, and because of this, the JDK with the development functionality will have both a client-nature JVM and a server-nature JVM under its own JRE, and only the jvm.dll of the client-only environment under the runtime will suffice.

Remember to set the Jdk/bin path in the environment variable path? This should be the first step for everyone to learn Java, the teacher will tell you not to set the words Javac and Java is not 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!

So someone's going to 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 when installing the JRE, the installer automatically helps you to add the Java.exe of the JRE to the system variables, the verification method is very simple, we see the system environment variable path at the front of the "%systemroot%system32;%systemroot%;" Such a configuration, then go to windows/system32 below to see it, found what? There is a java.exe.

If you force the ability to move Jdk/bin to the system32 variable, you can certainly force the use of Java in Jdk/jre, but I don't recommend it unless it's necessary. Running a Java program with a separate JRE is also a test in a customer environment.

------------------------------------------------------------------

Simply put, the JDK is a developer-oriented SDK that provides a Java development environment and a running environment. The SDK is software Development Kit generally refers to a software development package, which can include function libraries, compiler programs, and so on.
JDK is Java development Kit
The JRE is Java runtime enviroment, which refers to the Java Runtime Environment, and is intended for users of Java programs, not developers.

If the JDK is installed, there will be two sets of JRE on your computer, one in the/jre and one in the C:/Program files/java/j2re1.4.1_01 directory, and the other Java virtual machine, which is less server-side than the previous set. But just copy the server-side Java Virtual machine in front of you. You can also choose whether to install the JRE located in the C:/Program files/jav a directory when installing the JDK. If you install only the JRE, not the JDK, only a single set of JRE will be installed in the C:/Program Files/java directory.

The JRE is like a PC, and our WIN32 application requires the operating system to run it, and the Java program we write must also have the JRE to run. So when you're finished installing the JDK, if you have two sets of JRE installed in two different places on your hard drive, you can imagine your computer has two virtual Java PCs, all with the ability to run Java programs. So we can say that if you have a JRE installed on your computer, you can run the JAV a application correctly.

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. As can be seen from the following example, first renamed Tools.jar to Tools1.jar, and then run Javac.exe, showing the following result: 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 2 9K, from here we can draw a conclusion. Is that the tool in the JDK 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 attach a set of JRE, so it is located in C:/Program files/ The JRE in the Java directory is used to run generic Java programs.

2, if a computer installed 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 the JRE according to the following order: There is no JRE in its own directory; the parent directory has no JRE; 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. The bin directory under the JVM JRE directory has two directories: server and client. This is where the real jvm.dll lies. 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 under the directory where the JRE resides.
---------------------------------------------------------------

Before the Java installation is the JDK, and in the company installed is J2re, a little confused the relationship between the Internet, search, as follows:

In layman's terms: The JDK is Java's development package, which includes JRE;JRE is just the Java Runtime Environment, and the JDK includes the same version of the JRE, including compilers and other tools

The JDK is an abbreviation for the Java SDK (Java Development Kit). It is a development environment that builds applications, Apple, and components that are published on the Java platform. The JDK is the foundation of all Java applications, and all Java applications are built on top of that. It is a set of APIs, or it can be said to be some Java Class. To become a Java programmer, the JDK is the most basic tool necessary.

The JRE is the abbreviation for the Java Runtime Environment (Java Runtime enviroment). It's basically the same concept as a Java virtual machine. In general, when talking about a specific product, you can say "JRE", and when it comes to a model in theory, we often use "Java Virtual machine". To use Java programs, the JRE is an essential environment.

If multiple versions of the JDK are installed in the machine, the following:

BEA Weblogic Server 7.0 comes with a set of jdk1.3.1_02
Download a new set of jdk1.4.1_02
JBuilder9 comes with a set of jkd1.4.1_02
Oracle 8.1.7 comes with a set of JRE1.1.7
Ration Rose comes with a set of JDK1.3
Dreamweaver comes with a set of JDK1.3

6 sets of JRE, each of which is installed in a different directory and does not affect each other. When executing java.exe in the console, the operating system looks for the JRE in the following way:

First find out if there is a JRE in the current directory
and find out if there's a JRE in the parent directory.
Then find the JRE in path
Registry Hkey_local_machine/software/javasoft/java Runtime environment/to see which JRE the key value of CurrentVersion points to

Transferred from: http://blog.csdn.net/yuyulover/article/details/4427527

Jdk:java Development Kit,java Developer Kit. This package is a software development kit (Sdk:software Development Kit) used by Java developers. There are a lot of development tools libraries, such as: library, compiler.


Jre:java runtime Kit, Java operating environment. It is primarily for users of Java programs.
When you have installed the JDK, you have already installed the JRE, which has two sets, one set directly in the Java installation directory: C:\Program files\ JAVA\JRE 1.6; Another set in the JDK directory: C:\Program files\ java\jdk\jre 1.6. The former is only the client's operating environment, the latter also contains the server side.
Here is what I have to say to illustrate my understanding:
“The JRE is like a pc, and our WIN32 application requires the operating system to run it, and the Java program we write must also have the JRE to run. So when you're finished installing the JDK, if you have two sets of JRE installed in two different places on your hard drive, you can imagine your computer has two virtual Java PCs, all with the ability to run Java programs. So we can say that if you have a JRE installed on your computer , you can run Java applications correctly. ”


Jvm:java Virtual Machine,java vm, this is the core part of Java. If Java is a very smart language, it can be varied, across a variety of platforms, it is almost like a genie, then the JVM is the soul of Java possessed. Each platform's operating system, Sun has a different JVM to deal with, so Java does not need to consider these problems.
Here are some illustrations:




Is the principle of the JVM:



Is the relationship of JDK,JRE,JVM:

JDK JRE Differences

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.