foreword
Why write this article, because I don't want to go to Baidu to search for other people's articles, so I write one for my own records.
1. Preparation
Because some readers said that Oracle needs an account to download, and you don’t want to go to the trouble of registering one, then you can download it through the download address 2, and you can download it directly with 0 points.
A JDK installer, this is version 1.8, because the new JDK version does not have any great highlights, as shown in the figure below,
2. Installation
Double-click the mouse to run,
Select "Yes", and then as shown below:
Click Next:
I do not modify the installation path of JDK here, so there is no need to change it, click Next:
During the installation process, a jre installation prompt box will pop up, as shown below:
No changes here, click next, and you'll see this:
Anyway, you are boring, why not talk about the meaning of this picture, Java has become the driver of 300 million people, Java belongs to the ORACLE company, friends who are in the background here should be more clear, and the new features of Java8 also make the replacement of JDK behind Java change. 90% of developers still choose Java8, and no one cares about the latest Java14, mainly because of the stability of Java8. Another point is that the JDK after Java may not be open source, which means that no matter what they do in the future, people who use the previous Java version will be generalized. At this time, the old fox Google is very cunning , use the new language, so the preferred language of the Android Studio compiler will become Kotlin instead of Java, which can be regarded as a rainy day. You should have installed it after reading these.
In this way, the installation is complete, click "Close", and then configure the environment variables.
3. Configure environment variables
Right-click "This PC" and select Properties, then a pop-up window will appear, click "Advanced System Settings"
As shown below:
Click "Environment Variables" and you will see a screen like this:
The key is the following content, user variables can be ignored:
So far you have completed all the preparation steps, the next step is to configure the environment:
1. Click "New" and a pop-up window will appear:
Variable name: JAVA_HOME
variable value: C:\Program Files\Java\jdk1.8.0_162 (JDK installation path, here is your own installation path)
After the input is complete, click Confirm, the first configuration is completed, and then proceed to the second step
2. Create a new CLASSPATH variable, the variable value is:
.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar ( note that there is a dot in front ), after configuration is as shown below, here can be copied and pasted.
Then click OK to save the variable and go to the third step
3. Configure the path , find the path, double-click or click edit
Then you can see that there are already a lot of content in the path, we create a new one at the end:
Enter separately
%JAVA_CLASS%\bin
%JAVA_HOME%\bin
Then click OK to save, and then click OK after you go out, and then click OK, so far the environment variable configuration is complete, and the next step is to test whether there is any problem with the environment variable configuration.
Fourth, check the environment variable configuration
1. win + r
Or search in the search bar运行
2. Enter cmd
and click OK
Enter javac
whether the environment variable is configured successfully
Enter java -version
to view the version number
Even if the above page appears, the installation is successful
6. If unsuccessful
%JAVA_CLASS%\bin
%JAVA_HOME%\bin Delete and replace
the newly configured environment variable path
with the above two values and try to execute the command.记住要重新开一个cmd