1. Download JDK
Download: HTTPS: //www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html
2. Install the JDK:
It can be set to the path you want to install.
3. Environment variable configuration
3.1 Environment Variables window opens
Right This PC (this computer) -> Properties (Properties) -> Advanced system settings (Advanced System Settings) -> Environment Variables (environment variables)
3.2 New JAVA_HOME variable
Copy the absolute path jdk
Click on New (New) button to add a system variable
Input:
Variable name: JAVA_HOME
variable value: <path just copied>
When finished click OK.
3.3 New / Modify CLASSPATH variable
If there CLASSPATH variable, select and click Edit (Edit) .
If not, click New (New) New.
Input / existing variable value is added later:
变量名:CLASSPATH
变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
点击 OK 保存。
3.4 修改Path 变量
双击系统变量(system varible)中的Path,并点击new
新建两条路径:
%JAVA_HOME%\bin %JAVA_HOME%\jre\bin
4. 检查是否安装成功
win + r 打开 cmd
输入 java,出现如下的指令提示,说明配置成功了