准备的文件
ZIP(http://www.rpmfind.net/linux/centos/7.8.2003/os/x86_64/Packages/zip-3.0-11.el7.x86_64.rpm)
UNZIP(http://www.rpmfind.net/linux/centos/7.8.2003/os/x86_64/Packages/unzip-6.0-21.el7.x86_64.rpm)
JDK (http://apache.soxinyang.com/#/down/f1b54d77df533af9d9de55cf3f4e2cea)
ZIP和UNZIP
上传后
rpm -ivh unzip-6.0-21.el7.x86_64.rpm
rpm -ivh zip-3.0-11.el7.x86_64.rpm
JDK
1.删除本机自带的
(1)查看当前JDK版本
java -version
(2)查询java所有套件
rpm -qa | grep java
本机自带的openJDK.png
(3)删除套件
noarch文件可以不用删除,其余用如下命令删除
需要用root用户
rpm -e --nodeps 名字
如果完全相同,可以直接用我的
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
rpm -e --nodeps java-1.6.0-openjdk-1.6.0.36-1.13.8.1.el7_1.x86_64
rpm -e --nodeps libguestfs-java-1.28.1-1.55.el7.centos.x86_64
rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.91-2.6.2.3.el7.x86_64
rpm -e --nodeps java-1.7.0-openjdk-devel-1.7.0.91-2.6.2.3.el7.x86_64
rpm -e --nodeps abrt-java-connector-1.0.6-9.el7.x86_64
rpm -e --nodeps nuxwdog-client-java-1.0.3-2.el7.x86_64
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
rpm -e --nodeps java-atk-wrapper-0.30.4-5.el7.x86_64
rpm -e --nodeps java-1.8.0-openjdk-devel-1.8.0.65-3.b17.el7.x86_64
rpm -e --nodeps java-1.6.0-openjdk-devel-1.6.0.36-1.13.8.1.el7_1.x86_64
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64
2.安装新JDK
(1)上传到/usr/local/java
[root@ohMyGod local]# mkdir /usr/local/java
[root@ohMyGod local]# cd /usr/local/java
上传JDK.png
(2)解压文件夹
[root@ohMyGod java]# tar -zxvf jdk-8u202-linux-x64.tar.gz
(3)修改环境变量
vim /etc/profile
在最后插入,注意替换自己的路径
#java environment
export JAVA_HOME=/usr/local/java/jdk1.8.0_202
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin
让配置生效
source /etc/profile
(4)验证一下
[root@ohMyGod java]# java -version
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
参考自
https://www.cnblogs.com/sxdcgaq8080/p/7492426.html
https://www.linuxidc.com/Linux/2016-09/134941.htm
https://blog.csdn.net/panxin801/article/details/106092414/
网友评论