Working with multiple SDK/JDK versions

Being an architect I have been working with many versions of Java, Maven, and other development tools. Initially, it was okay when I had to manage only one or two versions of Java. But now it has become a nightmare to manage even with the help of an IDE.

The headache of resetting JAVA_HOME and MAVEN_HOME, along with installing different versions of JREs and JDKs from different vendors becomes a hell to manage. On top of all that imaging having each project requiring different versions of JDK or Maven or Gradle to manage as a dependency of that project.
I was looking out for a solution and that's when I found out SDKMAN. A small and elegant tool that takes care of all these problems I have been struggling with. With this tool, it is a piece of cake to manage and install different versions of JDK, SDK, and even some build tools.


So to get started just download the binary and pass it to bash and that is it!
curl -s "" | bash
This will download and install it in the user's home directory in ~/.sdkman.
Check the version of installed SDK manager by:
sdk version
That is all it takes to install SDKMAN


SDKMAN has a concept of candidates which means every candidate is like an SDK for it. You can get a list of candidates using:
sdk list
This will give you all the SDKs managed by SDKMAN.
To check versions of a candidate you can use the same command by providing a candidate name like below:
sdk list java
This will give you an output like below:
Available Maven Versions
 > * 3.6.3                                                                      

+ - local version
* - installed
> - currently in use

Installing Candidates JDK/SDK

Let's say you want to install version 3.5.2 of maven for one of your projects.
I understand that we have mvnw for that but here it is an example without even having a wrapper.
sdk install maven 3.5.2
if you look at the help command you'll know the syntax of the command is like sdk install <candidate> <version>. For some candidates, SDKMAN takes a default version. Like for java, it will take the latest stable version, which is 11.0.3.hs-adpt from AdoptOpenJDK.
If you have multiple versions of an SDK/JDK to switch between them use:
sdk use java 11.0.3.hs-adpt
This will make the current shell use java version 11.0.3. But this is not always useful. Let us say we want to have a default version of 8.0.262-zulu which is from, we can set this with below command.
sdk default java 8.0.262-zulu

Use project-specific versions

SDKMAN has this beautiful capability of environment-specific SDK setup. Let us say you have a project where you need a specific version of Java and Maven.
To achieve this goal, just create a .sdkmanrc file in the project root directory and add the candidate name as key and version number as value.
Use below command to create .sdkmanrc in the current working directory.
sdk env init
Edit .sdkmanrc file to add java and maven versions as below:
Now to make the current shell use versions specified in .sdkmanrc then issue below command.
sdk env
There are many more features available which you can check out on their docs pages(

Popular Posts