Ubuntu – How to “install” multiple Java versions

javajdk

How do you have multiple Java versions in Ubuntu 18.04 LTS?

In my Windows, I usually have 3 versions available for development. I do not have them installed in my system but rather, I can switch to different versions when I need to by pointing to the right jdk in Environment Variables. How can you do this in Ubuntu?

Best Answer

Check available versions with some search like:

apt --names-only search "openjdk-.*jre$"

Switch between versions with:

sudo update-alternatives --config java