SDKMAN! Managing JDK versions

Sometimes you need more than a version of JDK (Java Development Kit) in your machine to run different projects. Do Install manually of many versions, downloading bin files and configuring classpath on the environment could be pretty annoying.

SDKMAN! has saved me a lot of time on install, update and also set a JDK version as default on my machine, or even using a different version in only a session of your terminal.

Installation

Not much to say about it, it is simple as much use it. If you a Linux or Mac user, running the following command you should have the SDKMAN installed:

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

If you need to install SDKMAN on Windows, please follow the instruction here. After the installation, all following commands should work independently of your OS.

Usage

As you see, you cannot only install Java but also many things related to the JVM, like Maven, Gradle, Scala and some other CLI tools that help us daily. To see all tools (a.k.a. candidates) available, execute:

sdk list

You should see a long list with a name, a small description and the latest version of each candidate.

You also could use sdk ls for short.

In this case, I will install the Java so, to do it, just run:

sdk install java

At the end of the installation, SDKMAN asks you if you what set this version as default if you say yes, all new terminals will use this version. You can change it whenever you want, I will show you how.

The install command will always install the last version of the candidate, but as you know after version 8 of Java, we have many of vendor distributions, and if you want a specific one, you can list all the distributions/versions available, running:

sdk list java	

Now you should see a long list with vendor name, a column use (this show which version you are currently using as default), version, distribution and the most important, identifier, which we will use to install the specific version. After choosing your Java flavor, use the same install command with the identifier, like this:

sdk install java 8.0.242.hs-adpt

If you want to change the default version of a candidate installed you should run:

sdk default java 14.0.0.hs-adpt

And also you could use a version for just a session of your terminal, for this, execute:

sdk use java 8.0.242.hs-adpt

So, this was a quick view of how you can manage many version of JDK in your machine, if you want to know more about it, check out SDKMAN’s page and give it a try, I am sure this will make your life so much easier.

Voltar