Member-only story

Support multiple JDKs in Debian Linux

Marco Massenzio
4 min readDec 29, 2020

With the relatively recent change in the frequency of Java releases (every six months) it has become pretty much required to be able to have multiple JDKs on one’s development machine, and being able to run/test them at different times, for different projects, or even for the same project.

Originally published at http://codetrips.com on December 29, 2020.

Motivation

While some wizardry with symlinks and similar hackery is possible, on Ubuntu the alternatives system allows a relatively simpler approach.

If one contents oneself with simply having java and javac with alternatives[0], it is simply a matter of running something like:

sudo update-alternatives --install /usr/bin/javac javac \
/usr/lib/jvm/jdk-10.0.2/bin/javac 1010

assuming that one has untarred the OpenJDK tarball for JDK 10 in the above directory (and similarly for javac) [1].

However, the whole JRE/JDK package contains in excess of 20 binaries, and having a mish-mash of them is a sure recipe for disaster (best case scenario: weird issues and time wasted chasing red herrings).

A much better alternative is to use update-java-alternatives; however:

  1. this requires a laborious process of “configuring” the…

No responses yet

Write a response