跳至主要內容

Centos多版本Java切换

LinuxJavaLinuxJava小于 1 分钟约 108 字全民制作人ikun

Centos多版本Java切换

image-20240707084611598
image-20240707084611598

我在/root/tools/java目录下下载了两个Java的安装包

alternatives --install /usr/bin/java java /root/tools/java/jdk-21.0.3/bin/java 1
alternatives --install /usr/bin/java java /root/tools/java/jdk1.8.0_411/bin/java 2

Javac同理可以更换

alternatives --install /usr/bin/javac javac /root/tools/java/jdk-21.0.3/bin/javac 1
alternatives --install /usr/bin/javac javac /root/tools/java/jdk1.8.0_411/bin/javac 2

需要把之前配置的环境变量删除:

image-20240707085056630
image-20240707085056630

使用:

alternatives --config java
image-20240707085027367
image-20240707085027367
上次编辑于:
贡献者: yunfeidog