What are JDK and JRE? What is the purpose? (Post)
Article category: Java programming
You must choose whether to install a separate JRE when installing JDK. It is usually installed together. I also recommend that you do this.
This helps you better understand the differences between them:
JRE is the Java Runtime Environment and the execution environment of Java programs. Since it is execution, of course, the JVM should be included, that is, the familiar virtual machine, and all the class files of the Java class library should be packaged into jar in the Lib folder. You can verify it by yourself. Which file is the virtual machine on windows? Anyone who has learned MFC knows what DLL files are. So let's see if there is a JVM. dll in JRE/bin/client? That is, virtual machines.
JDK is a Java development kit and a Java Development Kit, which includes various class libraries and tools. Of course, it also includes another JRE. So why should we include another JRE? In addition, JDK/JRE/bin contains a JVM. dll in both the client and server directories at the same time. There are two virtual machines. I don't know if you have noticed this yet?
I believe everyone knows that JDK's bin contains the commands required by various Java programs. The most obvious difference with the bin folder of JRE is that javac is available under JDK, which is very easy to understand, JRE is only an execution environment. It has nothing to do with development. Because of this, JDK's own JRE with the development function will have a client JVM and a server JVM at the same time, the JRE, which is used only as the execution environment, requires only client JVM. DLL is enough.
Do you 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 everyone that javac and Java will not be used if they are not set. The JDK/bin folder contains all the commands. But has anyone ever wondered whether the Java command we use is not in the JDK/bin folder but in the JRE/bin folder? I don't believe I can do an experiment. You can cut the java.exe folder under the JDK/binfile to another place and then execute the Java program. What did you find? Everything is OK!
So someone will ask? Why didn't I set the JRE/bin folder to the environment variable?
Suppose that Java is not required for JDK development to be provided to most people, and JRE can be used to run Java programs, so every customer needs to manually set environment variables. How troublesome is it? When jreinstallation is started, can you add jre's java.exe? In the system variables, the verification method is very easy. We can see that the system environment variable path is prefixed with "% SystemRoot %/system32; % SystemRoot %, so let's go to Windows/system32 or lower to see what we found? There is a java.exe.
If we can forcibly move JDK/bin to the front of the System32 variable, we can also force the use of Java in JDK/JRE, unless necessary, I do not recommend that you do this. Using a separate JRE to run a Java program is also a trial in the customer's environment.
Now, we should be more clear about the internal connections and differences between JDK and JRE?
What are JDK and JRE? What is the purpose? (Post)