1. First download jdk from the official website
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
(I downloaded it to the E disk, taking jdk 1.8 as an example, the most used version at present, other versions install and configure the environment variable step is the same)
2. Installation
1. Double-click to open jdk, as shown in the figure, and then click Next
2. Click the Change button to specify the installation path, of course, you can not change it
(I installed it to E:\Java\jdk1.8.0_191)
3. After clicking Next, then Click Next to enter the installation progress. After the jdk installation is completed, the jre installation will be upgraded, and the installation path can also be changed.
4. Enter the installation state, after the installation is complete, you can configure it
3. Configure environment variables
1. Right-click the "Computer" icon on the desktop and select Properties from the menu. Open the System Properties window, select "Advanced System Settings" from the left menu, and click Environment Variables
2. In the system variable below, click New, enter the variable name JAVA_HOME, the variable value is the installation path of jdk, in this example it is E:\Java\jdk1.8.0_191\, and then click OK.
3. System Variables→Find the Path variable→Edit
Enter %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin; at the end of the variable value
(Pay attention to whether there is a ; number at the end of the original Path variable value, if not, enter the ; number first and then enter the above code)
4. System variables → create a new CLASSPATH variable
Fill in the variable value.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar (note that there is a point at the front). The
system variable configuration is complete.
5. Check whether the configuration is successful. Run cmd and enter java -version (there is a space between java and -version).
If the version information is displayed as shown in the figure, it means that the installation and configuration are successful.