centos7卸载自带jdk并安装jdk1.8

[root@hadoop103 software]# ls
hadoop-2.7.2.tar.gz jdk-8u144-linux-x64.tar.gz
[root@hadoop103 software]# java -version
openjdk version "1.8.0_222-ea"
OpenJDK Runtime Environment (build 1.8.0_222-ea-b03)
OpenJDK 64-Bit Server VM (build 25.222-b03, mixed mode)
[root@hadoop103 software]# rpm -qa |grep jdk
java-1.8.0-openjdk-1.8.0.222.b03-1.el7.x86_64
java-1.7.0-openjdk-1.7.0.221-2.6.18.1.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.222.b03-1.el7.x86_64
java-1.7.0-openjdk-headless-1.7.0.221-2.6.18.1.el7.x86_64
copy-jdk-configs-3.3-10.el7_5.noarch
[root@hadoop103 software]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.222.b03-1.el7.x86_64
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.221-2.6.18.1.el7.x86_64
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.222.b03-1.el7.x86_64
rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.221-2.6.18.1.el7.x86_64
rpm -e --nodeps copy-jdk-configs-3.3-10.el7_5.noarch
[root@hadoop103 software]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.221-2.6.18.1.el7.x86_64
[root@hadoop103 software]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.222.b03-1.el7.x86_64
[root@hadoop103 software]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.221-2.6.18.1.el7.x86_64
[root@hadoop103 software]# rpm -e --nodeps copy-jdk-configs-3.3-10.el7_5.noarch
[root@hadoop103 software]# java -version
-bash: /usr/bin/java: No such file or directory
[root@hadoop103 software]# tar -zxf jdk-8u144-linux-x64.tar.gz -C /opt/module/
[root@hadoop103 software]# cd ../module/jdk1.8.0_144/
[root@hadoop103 jdk1.8.0_144]# pwd
/opt/module/jdk1.8.0_144
## 此处需要转译'$' 实际应该为 echo -e "#JAVA_HOME\nexport JAVA_HOME=/opt/module/jdk1.8.0_144\nexport PATH=\$PATH:\$JAVA_HOME/bin" >> /etc/profile
[root@hadoop103 jdk1.8.0_144]# echo -e "#JAVA_HOME\nexport JAVA_HOME=/opt/module/jdk1.8.0_144\nexport PATH=$PATH:$JAVA_HOME/bin" >> /etc/profile
[root@hadoop103 jdk1.8.0_144]# tail -5 /etc/profile
unset i
unset -f pathmunge
#JAVA_HOME
export JAVA_HOME=/opt/module/jdk1.8.0_144
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/bin
[root@hadoop103 jdk1.8.0_144]# sed -i '$d' /etc/profile
[root@hadoop103 jdk1.8.0_144]# tail -5 /etc/profile

unset i
unset -f pathmunge
#JAVA_HOME
export JAVA_HOME=/opt/module/jdk1.8.0_144
[root@hadoop103 jdk1.8.0_144]# echo -e "export PATH=\$PATH:\$JAVA_HOME/bin" >> /etc/profile
[root@hadoop103 jdk1.8.0_144]# tail -5 /etc/profile
unset i
unset -f pathmunge
#JAVA_HOME
export JAVA_HOME=/opt/module/jdk1.8.0_144
export PATH=$PATH:$JAVA_HOME/bin
[root@hadoop103 jdk1.8.0_144]# source /etc/profile
[root@hadoop103 jdk1.8.0_144]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
[root@hadoop103 jdk1.8.0_144]# javac -version
javac 1.8.0_144

posted @ 2021-01-23 12:11  爬上巨人的肩膀  阅读(285)  评论(0编辑  收藏  举报