Java configures JDK environment variables and automatically installs JRE (detailed)

Write it in front (what is JDK, JRE)

        1.JDK: The Java Development Kit.

        2.JRE: The Java runtime environment.

1. Download and configure JDK

        1. Find the java development kit JDK you need to download on the official website, the address is as follows:

                                        Java Downloads | Oracle (click the link to jump)

 

2. After the download is complete, follow the prompts to install the JDK, and use the default installation path directly (to avoid problems with the environment configuration) . When installing JDK, JRE is generally installed. If it is not installed, please continue to read this article. The next part of this article is the "Installing JRE" method. 

3. Configure the environment (win7/win10 style is slightly different, the method is the same)

(1) Right-click the My Computer icon, select "Properties", find "Advanced System Settings" and open it.

 

(2) Select the "Advanced" tab and click the "Environment Variables" option.

 

(3) Next, we need to set 3 attributes, namely JAVA_HOME , PATH , CLASSPATH. If the corresponding variable name already exists, click "Edit", modify the path and save it; if it does not exist, click "New" and enter the path and save. The name and path are as follows, explained in 3 steps:

        Step 1: Set the CLASSPATH property.

        Click "New", enter the variable name and copy path (all marked in red) into the variable value box, and click "OK", as shown in the following figure.

Variable value:  .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar  (note: " . " at the beginning)

 

        Step 2: Set the JAVA_HOME property.

        Click "New", enter the variable name, find the full name corresponding to the jdk according to the path where you installed the JDK and copy it to the variable value box (especially important, you can't make mistakes, it is recommended to copy it)  , click "OK", as shown in the figure below.

 

        Step 3: Set the JAVA_HOME property .

                1--> Find and select "path", click "Edit".

                2--> Click "New" and enter the first command :     %JAVA_HOME%\bin

                3--> Click "New" again and enter the second command :    %JAVA_HOME%\jre\bin

                4--> Then click "OK".

 

(4) After the setting is completed, click "OK".

 

(5) Click "OK".

(6) Test whether "JDK" is successfully installed

       Step 1: Take Windows10 as an example: Enter cmd in the search box to open the command prompt.

                   (If you use Windows7, press and hold "Win + R", open the search box, enter cmd, and press Enter to open it.)

 

        Step 2: Enter the "java -version" command and press Enter to view the configuration information, and the configuration is complete.

 

2. Automatically install JRE (take jdk11 as an example)


1. (Take windo10 as an example) Search for cmd on the taskbar, right-click the mouse, and select run as administrator.

      (If using Windows 7, click the "Start" icon (the Win icon in the bottom left corner of the screen), select "All Programs", find "Accessories", find "Command Prompt" in the accessories, right-click "Command Prompt" , select Run as administrator.)

 

2. ( According to the path of the JDK you installed, ) Open the jdk11 folder directory and copy the directory path.

 

3. Enter cd in the command prompt box, paste the copied jdk folder directory location, and press Enter.

        For example: cd C:\Program Files\Java\jdk-11.0.12 ( note that there is a space after cd and then paste the path )

 

4. Copy the line statement after the pop-up command: bin\jlink.exe --module-path jmods --add-modules java.desktop --output jre , press Enter and wait for the installation to succeed. (Other versions operate the same)

 

Guess you like

Origin blog.csdn.net/m0_54158068/article/details/124415131