Linux卸载openjdk并安装Oracle jdk

Linux卸载openjdk


#查看版本
java -version

显示如下: 自带的openjdk
openjdk version "1.8.0_275"
OpenJDK Runtime Environment (build 1.8.0_275-b01)
OpenJDK 64-Bit Server VM (build 25.275-b01, mixed mode)

#查看jdk安装软件
rpm -qa|grep java

显示如下:
java-1.8.0-openjdk-1.8.0.275.b01-0.el7_9.x86_64
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.275.b01-0.el7_9.x86_64
python-javapackages-3.4.1-11.el7.noarch
tzdata-java-2020d-2.el7.noarch

#卸载openjdk   
#.noarch结尾的可以不用删除
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.275.b01-0.el7_9.x86_64
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.275.b01-0.el7_9.x86_64

安装Oracle jdk

官方下载地址: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
下载Linux x86版本: jdk-8u275-linux-x64.tar.gz


#解压
tar -zxvf jdk-8u275-linux-x64.tar.gz

#查看目录
pwd
/home/software/jdk1.8.0_275

#设置环境变量
vim /etc/profile
#末尾添加
export JAVA_HOME=/home/software/jdk1.8.0_275
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

:wq!
#保存退出

#使配置生效
source /etc/profile

#查看版本
java -version
显示如下:
java version "1.8.0_275"
Java(TM) SE Runtime Environment (build 1.8.0_275-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.275-b11, mixed mode)

参考链接: https://www.cnblogs.com/yyjf/p/10287301.html

你可能感兴趣的:(linux,linux,jdk,openjdk)