The relationship between Jdk,jre and JVM in Java Learning Java (reprint)

Source: Internet
Author: User

recently, we have to take a new look at Java, scan the technical documentation and save it for your own review . The following reprint from Http://www.cnblogs.com/xiaofeixiang/p/4085159.html

Beginner Java is easy to be confused by many of the concepts, first of all conceptually understand it, JDK (Java Development Kit) Simple understanding is the Java Development Kit, JRE (Java Runtime enviroment) Is the Java runtime Environment, where the JVM (Java Virtual machine) is often heard by Java VMs. JDK is for developers, the JRE is for the use of Java program users, the above is just a simple difference, general online a lot of concepts, I will not speak, directly should be clearer, I installed the JDK1.8, effect:

JDK and JRE

By discovering that there are two JRE folders, if you look at the contents of the content is basically the same, if it is only Java program users, then there will only be the outermost JRE directory, the JDK is the JRE comes with, If you install a JDK, you will inevitably have a JRE in it. So the question comes, why would there be two sets of JRE?

When you first use Java to set the Java environment variable, in addition to setting the path to the JDK in Java_home, you will need to set the Classpath,%java_home%\lib\dt.jar;%java_home%\lib\ Tools.jar;dt.jar and Tools.jar are the two most basic Java packages that contain the most important lang packets from Java to various advanced functions such as the visual Swing package, which is essential for Java.  And the bin below the path is Java executable compiler and its tools, such as Java,javadoc, you run cmd under any folder type Javac, the system can automatically summon Java compiler is attributed to this environment variable setting If you modify the name of Tools.jar, CMD will run with an error:

The reason for the error is that the input Javac command is not to go to the JDK Bin directory to find the Javac.exe, but to the JDK in the Lib directory Tools.jar in Com.sun.tools.javac.Main execution, so Javac.exe is just a wrapper (Wrapper ), the purpose of the existence is to keep the developer from entering too long a finger. At this point, it was found that the tools in the JDK were written almost in Java and belonged to Java applications, so the Java program was developed using the tools attached to the JDK, so it needed to be run with a set of JRE. The JRE in the sibling directory with JDK is used to run generic Java programs.

Which of the two sets of JRE is running, and this time the JDK Java.exe from its own directory, and then the parent directory to look for, if not all go to the registry to find:

So Java.exe's running results have a lot to do with which JRE in your computer is being executed, and the JDK and JRE should be all done, and here's the JRE and JVM.

JRE and JVM

JVM-Java Virtual MACHINEJVM is what we often call the Java VM, it is the entire Java implementation of the most cross-platform part of the core, All Java programs are first compiled into a. class file, which can be executed on a virtual machine, and the class file 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, similar to the CLR in C #.

The JVM cannot take care of class execution alone, and the JVM needs to invoke the class library lib that explains it when the class is interpreted. In the JRE directory below the JDK there are two folders Bin and Lib, where it can be thought that the bin is the jvm,lib in the JVM is required to work the class library, and the JVM and Lib are called the JRE. JVM+LIB=JRE, if the specific point is the bin directory under the Jvm.dll file, Jvm.dll can not work alone, when Jvm.dll boot, will use the explicit method (that is, using Win32 API LoadLibrary () With GetProcAddress () to load auxiliary dynamic-link libraries), and these auxiliary dynamic-link libraries (. dll) must be in the parent directory of the directory where 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.

The JDK is still a vague concept, which can be viewed from the JDK directory file at this time:

Under the directory there are five folders, a SRC class library source code compression package and a few declaration files, the other five folders are: Bin, db, include, LIB, jre,db this file to see business needs ~

Bin: The most important is the compiler (Javac.exe);

DB:JDK has built the derby database since 1.6, which is a pure Java-implemented memory database that belongs to an Apache open source project. Implemented in Java, so it can be run on any platform, and another feature is a small size, no installation, just a few small jar packages to run.

Include:java and JVM interaction with the header file;

LIB: Common class libraries

Jre:java Operating Environment

The JDK contains the JRE, and the JRE contains the JVM, which in general is used for the development of Java programs, while the JRE is a function that only runs class without compiling, and other Ides, such as Eclipse, IntelliJ idea, have their own compilers rather than JDK Bin directory, so in the installation only need to select the JRE path is OK, and finally with a network image summary:

The relationship between Jdk,jre and JVM in Java Learning Java (reprint)

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.