1.卸载openjdk
sudo apt-get --purge remove openjdk-8-jre-headless
2.添加环境变量
vim /etc/profile
#set java environment
JAVA_HOME=/usr/java/jdk1.7.0_79
JRE_HOME=/usr/java/jdk1.7.0_79/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效:
source /etc/profile
3.删除openjdk的链接
1.查找位置
which java
2.彻底删除链接
cd /usr/bin
2.1查找另一个软连接
ls -l | grep java
root@zhangsail:/usr/bin#lrwxrwxrwx 1 root root 22 1月 2 11:50 java -> /etc/alternatives/java
2.2删除两个软连接
rm -rf java
rm -rf /etc/alternatives/java
java -version
bash: /usr/bin/java: 没有那个文件或目录
3.重新使环境变量生效
source /etc/profile
root@zhangsail:/usr/bin# java -version
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=gasp
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
参考:
https://blog.csdn.net/jxpxlinkui/article/details/79649204
https://blog.51cto.com/vvxyz/1642258
https://blog.csdn.net/weixin_37550903/article/details/80672580
网友评论