前景提要
1.安装jdk8
[root@localhost ~]# sudo yum install java-1.8.0-openjdk
[root@localhost ~]# java -version
openjdk version "1.8.0_412"
OpenJDK Runtime Environment (build 1.8.0_412-b08)
OpenJDK 64-Bit Server VM (build 25.412-b08, mixed mode)
2.安装tomcat
sudo yum install tomcat
3.查询jdk版本
[root@localhost tmp]# java -version
openjdk version "11.0.23" 2024-04-16 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.23.0.9-2) (build 11.0.23+9-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.23.0.9-2) (build 11.0.23+9-LTS, mixed mode, sharing)
jdk版本变成了11,一下子头就大了!!
导致原因
第1步我们安装jdk8没任何问题,第2步咱们安装了tomcat,问题来了,这个tomcat的包中会引导安装jdk11。
解决办法
删掉tomcat? 那确实能解决问题,但是我既想要jdk8也想要tomcat怎么办呢?
这里用到切换java源工具
[root@localhost tmp]# java -version
openjdk version "11.0.23" 2024-04-16 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.23.0.9-2) (build 11.0.23+9-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.23.0.9-2) (build 11.0.23+9-LTS, mixed mode, sharing)
[root@localhost tmp]# alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.412.b08-2.el9.x86_64/jre/bin/java)
*+ 2 java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.23.0.9-3.el9.x86_64/bin/java)
Enter to keep the current selection[+], or type selection number: 1
[root@localhost tmp]# java -version
openjdk version "1.8.0_412"
OpenJDK Runtime Environment (build 1.8.0_412-b08)
OpenJDK 64-Bit Server VM (build 25.412-b08, mixed mode)
一目了然,咱们输入对应的序号进行切换,大功告成🎉🎉🎉🎉🎉
评论区