1.首先,检查已安装的jdk版本
sudo yum list installed | grep java
2.移除、卸载圈红的系统自带的openjdk
sudo yum remove java-1.7.0-openjdk.x86_64
sudo yum remove java-1.7.0-openjdk-headless.x86_64
sudo yum remove java-1.8.0-openjdk.x86_64
sudo yum remove java-1.8.0-openjdk-headless.x86_64
3.配置环境变量并使其生效
1) 编辑/etc/profile
vi /etc/profile
添加如下内容:
export JAVA_HOME=/usr/java/jdk-14.0.2
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
2) 使/etc/profile生效
source /etc/profile
4.查看oracle jdk是否配置成功
java -version