用update-alternatives管理java版本
1. 将新安装的oracle jdk加入 update-alternatives 管理范围:
# --install needs <link> <name> <path> <priority> sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-11.0.9/bin/java 300 sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-11.0.9/bin/javac 300
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-11.0.9/bin/jar 300
sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/jdk-11.0.9/bin/javah 300
sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk-11.0.9/bin/javap 300
2. 选择:
sudo update-alternatives --config java sudo update-alternatives --config javac
参考:
https://www.cnblogs.com/cocowool/p/change_openjdk_to_oraclejdk.html
https://www.linuxbabe.com/ubuntu/install-oracle-java-8-openjdk-11-ubuntu-18-04-18-10