In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to understand the difference and connection between JRE and JVM. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Are you familiar with the concepts of JRE and JVM? here's the difference between them. All Java programs can only be run under JRE. JDK's tool is also a Java program, which also requires JRE to run. In order to maintain the independence and integrity of JDK, JRE is also part of the installation of JDK. Let's first look at the concepts of both.
The difference between JRE and JVM
◆ JRE (JavaRuntimeEnvironment,Java runtime environment), that is, the Java platform. All Java programs can only be run under JRE. JDK's tool is also a Java program, which also requires JRE to run. In order to maintain the independence and integrity of JDK, JRE is also part of the installation of JDK. Therefore, under the installation directory of JDK, there is a directory called jre, which is used to store JRE files.
The ◆ JVM (JavaVirtualMachine,Java virtual machine) is part of JRE. It is a fictional computer, which is realized by simulating various computer functions on the actual computer. JVM has its own perfect hardware architecture, such as processors, stacks, registers, etc., as well as corresponding instruction systems. The most important feature of the Java language is that it runs across platforms. JVM is used to support operating system independent, cross-platform implementation.
If JDK is installed, there will be two sets of JRE on your computer, one in\ jre and the other in the C:\ Program Files\ Java\ j2re1.4.1_01 directory. The latter set is less than the previous set of server-side Java virtual machines, but just copy the previous set of Server-side Java virtual machines. And when installing JDK, you can choose whether or not to install the JRE located in the C:\ Program Files\ Java directory.
If you only install JRE, not JDK, then only one set of JRE will be installed in the C:\ Program Files\ Java directory.
The status of JRE is like a PC, the Win32 applications we write need the operating system to help us run, similarly, the Java programs we write must also need JRE to run. So after you install JDK, if you install two sets of JRE in two different places on your hard drive, you can imagine that your computer has two virtual Java PCs, both of which can run Java programs. So we can say that as long as your computer has JRE installed, you can run Java applications correctly.
1. Why does Sun want JDK to install two identical sets of JRE?
This is because there are a lot of development tools written in Java (such as javac.exe, jar.exe, etc.) in JDK, and they are all placed in\ lib\ tools.jar. As you can see from the following example, rename tools.jar to tools1.jar, and then run javac.exe to show the following result:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
This means that you enter javac.exe and type
Java-cp c:\ jdk\ lib\ tools.jar com.sun.tools.javac.Main is the same and will get the same result.
From here we can prove that javac.exe is just a Wrapper, and it is designed to save developers from typing too long instructions. And we can find that the programs in the\ lib directory are very small, no more than 29K, from which we can draw a conclusion. Even the tools in JDK are almost written in Java, so they are also Java applications, so if you want to use the tools attached to JDK to develop Java programs, you must have your own set of JRE, so the set of JRE located in the C:\ Program Files\ Java directory 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 to java.exe. Java.exe 's job is to find the right JRE to run the Java program.
Java.exe looks for JRE in the following order:
Is there any JRE in your own directory?
Is there a JRE in the parent directory
Query the registry:
[HKEY_LOCAL_MACHINE\ SOFTWARE\ JavaSoft\ Java Runtime Environment]
So the running result of java.exe has a lot to do with which JRE is executed on your computer.
3. Introduce JVM
The Bin directory under the JRE directory has two directories: server and client. This is where the real jvm.dll is.
Jvm.dll cannot work alone, and when jvm.dll starts, it uses explicit's method (that is, using LoadLibrary () and GetProcAddress () in Win32 API to load auxiliary dynamic link libraries), and these auxiliary dynamic link libraries (.dll) must be located in the parent directory of the directory where jvm.dll is located.
So which JVM you want to use, just set PATH and point to the jvm.dll under the directory where JRE is located.
On how to understand the difference between JRE and JVM and what is the connection to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.