Installation of the Java environment

The installation of Java environment is not like MySQL, which supports zip decompression installation (see MySQL installation details), but requires the installation of files (although it is a file installation, but the location of the later download can also be customized, the downloaded files are in a folder, the effect is similar to the green version).

During the installation process, it first asks for the JDK to be installed, with the default location C:\Program Files (which can be customized), but then it asks for a JRE to be installed, asking the user to choose the installation location, as shown below.

We know that the JDK stands for Java SE Development Kit (SE stands for Stardard, Edition), which is a set of Development packages for developing Java programs. Obviously, it is specifically for developers. Since it is designed for developers, it must include a range of tools and resources needed to compile and run Java programs.

There will also be a folder called JRE. As shown in the figure below.

JRE — Java Runtime Environment (JRE), as the name implies, is a condition for running Java programs.

Since the JDK has the JRE, why install the JRE for the default C disk when we finish installing the JDK? Can this not be installed? Isn’t it enough to have that JRE in the JDK folder?

Explanation:

It turned out that the two jres were installed to share the work.

If the user is only executing Java programs, then the environment with JRE is ok. If the user is a developer who needs to compile and run the command, the system will look for the parent path (environment variable) of the command containing Java, javac, etc., that is, the JRE under the JDK. This way, when running an external program, you will find the JRE; In the development of the program, looking for the JDK under the JRE.

Another reason can be tested by doing it yourself. After the JRE is installed, the system automatically adds it to the system variable.

If you have installed the JDK and JRE and have not yet configured environment variables, you will find the following command line tests:

Java commands can be run directly. (Java commands are used to run compiled programs)

The javac command will say “Not internal command” (javac is used to compile the program to a.class file)

Command line execution We know that only commands with environment variables configured can execute programs like this.

Java commands are used to run the commands contained in the JRE. The javac command is used for compilation and is only available in the JDK. If the former can be executed but the latter cannot be executed, the installation program automatically configures environment variables for the JRE for public use. The JDK is for developers to use and needs to be manually configured.

Again, the JRE and JDK are for work sharing. This is why you need to install “two” JRes.

Refer to the link

Blog.csdn.net/ctx64563464…

Why are two JRes installed when installing the JDK? You do not need to configure jre environment variables