Install several versions of JDK, Gradle, Kotlin, Scala, Spark and … on your OS in parallel

General-purpose Software Development Kit Manager

You may hear about pyenv, RVM or NVM which allows Python, Ruby, and Node.js developers to have multiple versions of their development environment simultaneously and easily manage them (install and uninstall) and most importantly switch between those versions by running a simple command.

Formerly there was a tool called GVM (Groovy Environment Manager) that mostly used for managing parallel versions of Groovy, Grails, and Gradle on most Unix based systems.

SDKMAN! emerges

SDKMAN! is evolved, rebranded and generalized version GVM for managing parallel versions of any SDKs (Software Development Kits). By using SDKMAN! you can install and use several versions of any SDKs (from JDK to Apache Spark) in parallel on any operating systems which support bash, like Linux, macOS, or Windows (through WLS or Cygwin).

Benefits of SDKMAN!

Imagine you want to test and evaluate new features of JDK 14 or Gradle 6.0 on your machine along with you have installed other versions of those. By using SDKMAN! it is not a hassle and you can do your test by running a few commands and change your environment and after that revert it back.

SDKMAN! is not limited to JVM SDKs. Using SDKMAN! open Broker REST API, every team or company can publish their SDKs using SDKMAN!

How to install SDKMAN!

SDKMAN! is Written in bash and to install it you only need to have curl, zip, and unzip in your path.

Install on the UNIX-like operating systems (Linux, macOS or …)

SDKMAN! supports Bash and ZSH shells and you can easily install it by running this command:

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

Install on windows

According to SDKMAN! website’s documentation, you can install it on windows using Windows Linux Subsystem (WLS) or Cygwin or Git Bash for Windows easily by running the above command. You just need to have zip, unzip, and curl in your path.

If you have any problem to install zip and unzip using MinGW or Cygwin in tools like cmder or Git bash, you can use this link approach to download and use them manually.

How to use SDKMAN!

After the installation process is complete you should close the current terminal and open new one or run this command in the current terminal:

source "$HOME/.sdkman/bin/sdkman-init.sh"

For the first command you can run the version command to make sure the installation was successful:

sdk version //or sdk v

This command print the version of SDKMAN! that installed on your machine. If there is an update for SDKMAN! it will ask you for upgrading ( Would you like to upgrade now? (Y/n): ). If you want to update SDKMAN! to a new version you can run this command:

sdk selfupdate

Getting a list of all available SDKs (candidates) to install

You can get a list of available SDKs (candidates) such as JDK, Scala, Maven, Gradle and … using this command and search through the results:

sdk list //or sdk l

Getting a list of an SDK (candidate) versions

By using the following command you can get a list of all available version of an SDK:

sdk l java

The most important columns in the printed list are Status and Identifier (or Version for those SDK that does not have Vendor ) that indicate which versions of this SDK is installed on your machine and what is the identifier to install or remove those.

Installing an SDK

The fastest way to install an SDK on your machine is to install the latest stable version of the default vendor (if exist) of that SDK, by running the following command:

sdk i java

If you want to install a specific version you can use Version or Identifier :

sdk i scala 2.12.10

or

sdk i java 11.0.5-amzn

Installing a local version of an SDK

This feature is very useful for those who developing or testing snapshot or beta version of an SDK. If you already have a local installation of an SDK, you can install that local version by specifying the path to it and assign a unique name to it:

sdk i java openjdk-14-ea25 /path/to/ installation

Getting the currently installed version of SDKs

By the following command you can see what is the current version in use for an SDK:

sdk c java

or use this command to find what is the current version in use for all SDKs:

sdk c

Switching between the installed versions of an SDK (for current terminal)

When you can install several version of an SDK in parallel, it is very important to be able to switch between them, note that this command switches the version for the current terminal only:

sdk u java 11.0.5-amzn

Setting a version of SDK as the default (permanently for all terminal)

If you want to set a specific version of an SDKs as default (permanently for all terminal), you can use this command:

sdk d java 11.0.5-amzn

Conclusion

I found SDKMAN! very useful for cross SDK development and test and also implementing complicated deployment scripts scenario for projects that need several versions of an SDK in parallel.