In this article you will learn how to install and how to use sdkman. Sdkman (Software Development Kit Manager) is a tool to keep parallel versions of different SDKs on unix-based systems. You can easily switch between different versions without having to deal with changes in your $PATH variable. Let’s see how!
Installing SDKMAN is very easy. You can also check on their website, but it’s as simple as running this:
curl -s "https://get.sdkman.io" | bash
In order to check if the installation has been successfully completed, you can run this from the command line:
If everything goes well, you should be seeing something similar to this:
~ sdk version SDKMAN 5.16.0
Now that you have sdkman installed, let’s see how to use it. In our example we’ll see how to install java using sdkman.
Installing packages – Install Java with sdkman
To install a package (also called “candidate” in sdkman) you first need to know how is the candidate named in sdkman. In some cases is very intuitive, for example to install Java, the candidate name is just
java as expected.
In this case, installing the latest java version would be as simple as the following:
sdk install java
This will install the latest default version of Java into our sdkman configuration, the output should look similar to this:
~ sdk install java Downloading: java 17.0.5-tem ... Done repackaging... Cleaning up residual files... Installing: java 17.0.5-tem Done installing!
Now that you have installed your first package, what if you want to install a different version or even a different jdk distribution in the case of Java? What if you don’t even know the exact name of your package?
We can list candidates and their versions to get this information.
Listing packages and versions
First of all, if we don’t know the name of the package or even if we just want to check the available packages, we can run the
When you run this command, you will get a list in the following format:
The packages are sorted in alphabetical order, therefore you can scroll down and find whatever package it is you’re interested in.
If you want to know the existing versions for a given package, you can also use
list but specifying what package you are interested in. For instance:
sdk list java ================================================================================ Available Java Versions for macOS ARM 64bit ================================================================================ Vendor | Use | Version | Dist | Status | Identifier -------------------------------------------------------------------------------- Corretto | | 19 | amzn | | 19-amzn | | 19.0.1 | amzn | | 19.0.1-amzn | | 17.0.5 | amzn | | 17.0.5-amzn | | 17.0.4 | amzn | | 17.0.4-amzn | | 11.0.17 | amzn | | 11.0.17-amzn | | 11.0.16 | amzn | | 11.0.16-amzn | | 8.0.352 | amzn | | 8.0.352-amzn | | 8.0.342 | amzn | | 8.0.342-amzn Gluon | | 184.108.40.206.r17 | gln | | 220.127.116.11.r17-gln | | 18.104.22.168.r11 | gln | | 22.214.171.124.r11-gln GraalVM | | 22.3.r19 | grl | | 22.3.r19-grl | | 22.3.r17 | grl | | 22.3.r17-grl ...
You will be shown a list with all the existing vendors and their corresponding versions. Once you have selected your desired package, you will have to use the name displayed in the
For example, to install the latest JDK 19 Zulu version we should run:
sdk install java 19.0.1-zulu
Once you have multiple versions installed, you can see what versions you have installed when you list them. For example, the Zulu packages in our host has the following:
Zulu | | 19 | zulu | | 19-zulu | | 19.fx | zulu | | 19.fx-zulu | | 19.0.1 | zulu | installed | 19.0.1-zulu | | 19.0.1.fx | zulu | | 19.0.1.fx-zulu | >>> | 17.0.5 | zulu | installed | 17.0.5-zulu | | 17.0.5.fx | zulu | | 17.0.5.fx-zulu | | 126.96.36.199 | zulu | | 188.8.131.52-zulu | | 184.108.40.206.fx | zulu | | 220.127.116.11.fx-zulu | | 11.0.17 | zulu | | 11.0.17-zulu | | 11.0.17.fx | zulu | | 11.0.17.fx-zulu | | 18.104.22.168 | zulu | | 22.214.171.124-zulu | | 126.96.36.199.fx | zulu | | 188.8.131.52.fx-zulu | | 11.0.14 | zulu | local only | 11.0.14-zulu | | 8.0.352 | zulu | installed | 8.0.352-zulu | | 8.0.352.fx | zulu | | 8.0.352.fx-zulu | | 8.0.345 | zulu | | 8.0.345-zulu | | 8.0.345.fx | zulu | | 8.0.345.fx-zulu | | 8.0.322 | zulu | local only | 8.0.322-zulu
You will notice that the
Status column shows
installed for all those candidate versions you have installed on your machine. Also notice that the version currently in use is marked with
>>> in the
Use column (second column).
One more thing to know about
list command is that it is equivalent to
ls. You can also run
sdk ls java, for example.
How do we switch to another version then?
Once you’ve seen the installed versions in your machine, switching is as simple as running this.
~ sdk use java 19.0.1-zulu Using java version 19.0.1-zulu in this shell.
If we run
sdk list java again, now the version in use should have changed.
Zulu | | 19 | zulu | | 19-zulu | | 19.fx | zulu | | 19.fx-zulu | >>> | 19.0.1 | zulu | installed | 19.0.1-zulu | | 19.0.1.fx | zulu | | 19.0.1.fx-zulu | | 17.0.5 | zulu | installed | 17.0.5-zulu | | 17.0.5.fx | zulu | | 17.0.5.fx-zulu
As expected, the version in use now points to version
That sets the version to use in our current shell, what if we would like to set a given version as the default version to use if no other version is specified in the current session?
Setting default version
Setting a given version as the default version to use in our machine is very simple too. Let’s say we want to always use version
17.0.5-zulu as the default Java version, what command do we need to run? The required command for this purpose is shown below:
~ sdk default java 17.0.5-zulu Default java version set to 17.0.5-zulu
That’s quite straightforward as well, right?
That’s all you need to know about sdkman to make your life as a developer much easier!
In this article we’ve seen how to use sdkman to be able to switch to different versions in our machine in a very easy manner. By using sdkman we avoid having to modify our PATH variable every time that we want to use a different version of Java.
That’s all from us today! We hope you’ve found this article useful and we are looking forward to seeing you again very soon!
You must log in to post a comment.