一、Windows 配置
1 安装文件
jdk-8u401-windows-i586.exe
2 环境变量
JAVA_HOME
C:\Program Files (x86)\Java\jdk-1.8
CLASSPATH
.;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;
Path
%JAVA_HOME%\bin
说明:Win7/Win8 中 Path 可能需要写成 ;%JAVA_HOME%\bin
3 验证
C:\>java -version
java version "1.8.0_401"
Java(TM) SE Runtime Environment (build 1.8.0_401-b10)
Java HotSpot(TM) Client VM (build 25.401-b10, mixed mode, sharing)
二、Linux 配置
1 安装文件
jdk-8u401-linux-x64.tar.gz
2 查看是否有 jdk 并卸载
[root@localhost /]# java -version
openjdk version "1.8.0_412"
OpenJDK Runtime Environment (build 1.8.0_412-b08)
OpenJDK 64-Bit Server VM (build 25.412-b08, mixed mode)
[root@localhost /]# rpm -qa|grep jdk
copy-jdk-configs-3.3-10.el7_5.noarch
java-1.8.0-openjdk-headless-1.8.0.412.b08-1.el7_9.x86_64
java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64
[root@localhost /]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.412.b08-1.el7_9.x86_64
[root@localhost /]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.412.b08-1.el7_9.x86_64
[root@localhost /]# rpm -qa|grep jdk
copy-jdk-configs-3.3-10.el7_5.noarch
3 安装和配置环境变量
[root@localhost 下载]# ls
jdk-8u401-linux-x64.tar.gz
[root@localhost 下载]# mkdir -p /usr/local/java
[root@localhost 下载]# tar -zxvf jdk-8u401-linux-x64.tar.gz -C /usr/local/java/
[root@localhost 下载]# ls /usr/local/java
jdk1.8.0_401
[root@localhost 下载]# vim /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_401
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
[root@localhost 下载]# source /etc/profile
4 查看版本
[root@localhost 下载]# java -version
java version "1.8.0_401"
Java(TM) SE Runtime Environment (build 1.8.0_401-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.401-b10, mixed mode)
附录:
OpenJDK 下载:
https://openjdk.org/
https://jdk.java.net/java-se-ri/8-MR5
Oracle JDK 下载:
https://www.oracle.com/java/technologies/downloads/archive/
参考:
Java环境变量配置原因及教程——Path,JAVA_HOME,CLASSPATH 2020-07-12 20:44
https://zhuanlan.zhihu.com/p/153500777
JAVA环境变量的作用及配置
https://zhuanlan.zhihu.com/p/32485771
OpenJDK windows下安装过程
https://blog.csdn.net/jianzero/article/details/98483083
在使用上OracleJDK和OpenJDK有什么区别?
https://www.zhihu.com/question/327162941
使用yum卸载、安装jdk
https://cloud.tencent.com/developer/article/2095725?areaId=106001
Linux安装JDK1.8并配置环境变量
https://cloud.tencent.com/developer/article/2168275?areaId=106001
Linux上快速安装、卸载JDK「建议收藏」2022-09-12 17:58:57
https://cloud.tencent.com/developer/article/2103087?areaId=106001
ContOS7手动安装JDK
https://cloud.tencent.com/developer/article/2171965?areaId=106001
Linux安装JDK并配置环境变量 - 详细步骤 2021-01-04 16:25
https://zhuanlan.zhihu.com/p/341775533