📅 2015-Dec-01 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ jdk, jre, openjdk ⬩ 📚 Archive
The Ubuntu archives have multiple versions of OpenJDK available. One of these is designated as the default and this has the package names default-jdk
and default-jre
. The java
and javac
programs will be symlinked to the binaries from this default JDK. On my Ubuntu, the default packages were linked to the openjdk-11-jdk
and openjdk-11-jre
packages.
However, you might want to install and use other versions of JDK. For example, to use Java 8 I did:
$ sudo apt install openjdk-8-jdk
The problem is that java
, javac
and other binaries still point to the default Java version. To switch the default Java binaries, use the update-java-alternatives
tool.
--list
option:$ 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
--set
option:$ sudo update-java-alternatives --set java-1.8.0-openjdk-amd64
/usr/lib/jvm
and manually point the default-java
symbolic link to the directory I wanted:$ cd /usr/lib/jvm
$ ls
default-java
java-1.11.0-openjdk-amd64
java-11-openjdk-amd64
java-1.8.0-openjdk-amd64
java-8-openjdk-amd64
$ sudo rm -f default-java
$ sudo ln -s java-1.8.0-openjdk-amd64 default-java
Tried with: Ubuntu 18.04