$ file /etc/alternatives/java /etc/alternatives/javac
/etc/alternatives/java: symbolic link to /usr/lib/jvm/java-11-openjdk-amd64/bin/java
/etc/alternatives/javac: broken symbolic link to /usr/lib/jvm/java-11-openjdk-amd64/bin/javac
答案1
我安装了 Oracle JDK,而不是 OpenJDK,但是使用这些命令来添加符号链接。
将其添加到路径中。
export PATH="$PATH:/opt/java/jdk1.8.0_171/jre/bin"
创建符号链接。
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.8.0_171/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.8.0_171/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/java/jdk1.8.0_171/bin/javaws" 1 sudo update-alternatives --set java /opt/java/jdk1.8.0_171/bin/java sudo update-alternatives --set javac /opt/java/jdk1.8.0_171/bin/javac sudo update-alternatives --set javaws /opt/java/jdk1.8.0_171/bin/javaws