CentOS 7.3离线安装 JDK

1.下载对应的JDK版本

# 网盘链接:https://pan.baidu.com/s/1HMCJis-FEicIcDTgbksBnQ
# 密码:q65m

2.查看原系统jdk版本

[bw@localhost ~]$ java -version
openjdk version "1.8.0_102"
OpenJDK Runtime Environment (build 1.8.0_102-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)

3. 查看安装的信息

[bw@localhost ~]$ rpm -qa|grep java
java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64
python-javapackages-3.4.1-11.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
tzdata-java-2016g-2.el7.noarch

4.卸载OpenJDK

[bw@localhost ~]$ su root
Password: 
[root@localhost bw]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64
[root@localhost bw]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64
[root@localhost bw]# rpm -qa|grep java
python-javapackages-3.4.1-11.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
tzdata-java-2016g-2.el7.noarch

5.安装jdk

#解压至安装目录
tar -zxvf jdk-8u131-linux-x64.tar.gz -C /usr/local

6.设置环境变量

# 打开文件
vim /etc/profile

# 在末尾添加
export JAVA_HOME=/opt/jdk1.8.0_131
export PATH=$PATH:$JAVA_HOME/bin

# 使环境变量生效
source /etc/profile

# 检查
[root@localhost bw]# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

 

posted @ 2020-06-14 16:41  老虎死了还有狼  阅读(431)  评论(0编辑  收藏  举报