java版本恢复
java 版本问题
前提: 突然发现一台服务器因为java版本问题导致大数据服务的挂掉,恢复java版本
查看现有java版本
java -version
java version “17.0.6” 2023-01-17 LTS
Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)
查看其它大数据的java版本
java -version
java version “1.8.0_141”
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)
从官网下载对应版本
https://www.oracle.com/sg/java/technologies/javase/javase8-archive-downloads.html
下载的文件
jdk-8u141-linux-x64.tar.gz
查看现有java安装路径
ls -alh /usr/bin/java
lrwxrwxrwx 1 root root 22 Apr 6 11:56 /usr/bin/java -> /etc/alternatives/java
johnson@wacserver1:~/jvm$ ls -alh /etc/alternatives/java
lrwxrwxrwx 1 root root 34 Apr 6 12:06 /etc/alternatives/java -> /usr/lib/jvm/jdk-17/bin/java
解压tar包到对应目录
sudo tar -xzf jdk-8u141-linux-x64.tar.gz -C /usr/lib/jvm/
得到
/usr/lib/jvm/jdk1.8.0_141
更新默认java版本
sudo update-alternatives –install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_141/bin/java 1
sudo update-alternatives –install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_141/bin/javac 1
sudo update-alternatives –config java
sudo update-alternatives –config javac
有时需要系统的环境变量文件,对所有用户生效
/etc/profile
修改
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_141
export PATH=$JAVA_HOME/bin:$PATH