JDK JRE is saved in the back and then collated

Source: Internet
Author: User

1. Definition
The JRE (Java Runtime enviroment) is the Java Runtime 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 install a JDK, you will find that your computer has two sets of JRE, one in C:\Program Files\java\jre6 and the other in the C:\Program Files\java\jdk1.6.0_41\jre 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 if you install two sets of JRE in two different places on your hard disk after you've installed the JDK, you can imagine that your computer has two virtual Java
PC, all have the function of running Java program. 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 many development tools written in Java, such as Javac.exe, Jar.exe, etc., which are placed in the C:\Program Files\java\jdk1.6.0_41\bin directory.
Because they are Java-written commands, they rely on Java's jar packages, which are stored in the C:\Program files\java\jdk1.6.0_41\lib directory
If you rename the Tools.jar in the C:\Program files\java\jdk1.6.0_41\lib\ directory to Tools1.jar, and then run Javac.exe, the following results are displayed:
Exception in thread "main" Java.lang.noclassdeffounderror:com/sun/tools/javac/main
But input java-cp C:\Program Files\java\jdk1.6.0_41\lib\tools1.jar Com.sun.tools.javac.Main
Will get the same results as Javac.exe.
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 we can find the C:\Program files\java\jdk1.6.0_41\bin directory of the program is very small, not more than 29K, 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\java\jdk1.6.0_41\ The JRE in the JRE 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 the 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.

JDK JRE is saved in the back and then collated

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.