I have Java 8 and Java 11 installed in parallel on my Ubuntu 16.04 machine:
$ update-java-alternatives --list
java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64
Having selected Java 11 previously, I now wanted to switch to Java 8 using the command
$ sudo update-java-alternatives --set java-1.8.0-openjdk-amd64
Yet, only the symlink of /usr/bin/java
, but not /usr/bin/javac
is updated:
$ javac -version
javac 11.0.5
$ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~16.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
Why is this and how can it be fixed?
sudo update-alternatives --config java
does not work?java
orjavac
itselfupdate-alternatives
works fine, but the (Open)JDK consists of many more Java tools in both the JRE and the JDK. After all, the purpose ofupdate-java-alternatives
is to (conceptually) runupdate-alternatives
for all Java tools defined in the respective .jinfo file.