How to Install Java Alternatives in Ubuntu

This script will let you install Java alternatives in Ubuntu. In short, you can install multiple versions of Java and activate any one of them at a time.

For example, let's assume that you already have an OpenJDK version 11 installed and you want to install GraalVM as well. These are the commands to do it, we are adding GraalVM in slot 2.
sudo update-alternatives --install /usr/bin/java java /opt/graalvm-ce-java11-21.0.0/bin/java 2
sudo update-alternatives --install /usr/bin/javac javac /opt/graalvm-ce-java11-21.0.0/bin/javac 2
To change the active java version, execute:
sudo update-alternatives --config java
And select the desired version.

This is how you install OpenJDK 11 in Ubuntu: https://www.czetsuyatech.com/2021/03/install-openjdk-11-in-ubuntu.html

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post
NERV Open Source
Building production Spring Boot systems?

Explore NERV — open-source Java libraries for audit trails, persistence, exception handling, and reliable event-driven architecture.