SDKMAN is a tool to install multiple versions of JAVA in an operating system. This can be used to install multiple versions of Java in MacOS or any Linux operating system.

SDKMAN Website

we will learn to install Java in the Ubuntu operating system using SDKMAN

Check whether Java is installed or not

You can run the below command in your Linux terminal

java

When you run the java command then you will get an output that the command not found. This signifies that Java is not installed in your operating system

Install SDKMAN

Run the below command in your terminal to install SDKMAN

curl -s "https://get.sdkman.io" | bash

Once Installation is complete you will see a command at the bottom. In the above picture, I have pointed it using the arrow. This command will be different for your computer.

Copy the command and run it in the terminal

You need to check if the sdkman is successfully installed or not

sdk

Install a specific version of Java

You need to check what version of Java is available to be installed

sdk list java

The list can be huge. I am just showing you some sample output

You can see the rightmost column as an Identifier.

Copy the Identifier that you want to install.

In our case, we will install 11.0.21-amzn for the Corretto vendor. Then run the below command

sdk install java  11.0.21-amzn

This will install the Java-11

Open a new terminal and check the Java version

java --version

This time you will see the OpenJDK 11.0.21 installed

Install one more version of Java using SDKMAN

You can again list down the available Java vendor versions using the sdk list java command and then select a specific version for installation

In my case, I will install version 21.0.1 of Correto vendor so I will select the Identifier as 21.0.1-amzn

sdk install java  21.0.1-amzn

During the installation process, sdkman will ask if you want to make this new version the default one, and then you can submit your answer.

Find all the installed version

You will list the Java candidates

sdk list java

In the status column, you can see the text as installed. I have pointed it using an orange arrow. This signifies that these versions of Java are installed.

In the Use column, you can see three angle brackets >>>. This signifies the current version being used. I have pointed it out using Red Arrow

What is the default version meaning in SDKMAN

If you have multiple versions of Java installed on your operating system using SDKMAN then you can set one of the versions as the default version.

This means that if you open a new terminal or restart your machine then that version will be the default one.

Set Default Java Version

You can set the default version of your Java by selecting the appropriate Identifier and then using the below command

sdk default java 11.0.21-amzn

Use Any version of Java

If you don’t want to change the default version of your Java but only want to change the Java version in the current terminal then you can run the below command

sdk use java 21.0.1-amzn

You can see the output of the command using the Java version in this shell only.

Leave a Reply

Your email address will not be published. Required fields are marked *