What is SDKMAN!

SDKMAN! is a development tool that allows you to install and manage Java, Scala, Groovy, Maven and many other tools, libraries and programming languages united under JVM platform. It is created for GNU/Linux’s and MacOS’ users.

Installation

The first step is to paste this command in your terminal and submit it.

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

This will launch the process of installation, which might require your input. After successful installation paste this command and you are ready to work.

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

Usage

You can list all available versions of desired SDK using below command:

sdk list <sdk>

Here is output of this command for Groovy.

sdk list groovy

================================================================================
Available Groovy Versions
================================================================================
     3.0.0-alpha-1        2.4.12               2.3.1                2.0.8          
     2.6.0-alpha-2        2.4.11               2.3.0                2.0.7          
     2.6.0-alpha-1        2.4.10               2.2.2                2.0.6          
     2.5.0-beta-2         2.4.1                2.2.1                2.0.5          
     2.5.0-beta-1         2.4.0                2.2.0                2.0.4          
     2.5.0-alpha-1        2.3.9                2.1.9                2.0.3          
     2.4.9                2.3.8                2.1.8                2.0.2          
     2.4.8                2.3.7                2.1.7                2.0.1          
     2.4.7                2.3.6                2.1.6                2.0.0          
     2.4.6                2.3.5                2.1.5                1.8.9          
     2.4.5                2.3.4                2.1.4                1.8.8          
     2.4.4                2.3.3                2.1.3                1.8.7          
     2.4.3                2.3.2                2.1.2                1.8.6          
     2.4.2                2.3.11               2.1.1                1.8.5          
     2.4.13               2.3.10               2.1.0                1.8.4          

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

Installation is effortless. Select any of available versions or just skip it and install the currently stable version.

sdk install <sdk> (<version>)

Let’s try install Java 9. Paste sdk install java 9.0.1-zulu and hit Enter.

sdk install java 9.0.1-zulu

Downloading: java 9.0.1-zulu

In progress...

######################################################################## 100,0%

Repackaging Java 9.0.1-zulu...

Done repackaging...

Installing: java 9.0.1-zulu
Done installing!

Do you want java 9.0.1-zulu to be set as default? (Y/n): 

Setting java 9.0.1-zulu as default.

All installed Java versions will be available in the folder $SDKMAN_DIR/candiadates/java.

ls $SDKMAN_DIR/candidates/java -l
total 8
drwxr-xr-x.  9 wpanas wpanas 4096 10-18 17:44 8u152-zulu
drwxr-xr-x. 10 wpanas wpanas 4096 11-04 16:22 9.0.1-zulu
lrwxrwxrwx.  1 wpanas wpanas   47 12-25 17:23 current -> /home/wpanas/.sdkman/candidates/java/9.0.1-zulu

You can check if installation was successful by checking current Java version. The command java --version will not work in Java 8 or any previous, so let’s try it.

java --version
openjdk 9.0.1.3
OpenJDK Runtime Environment (Zulu build 9.0.1.3+11)
OpenJDK 64-Bit Server VM (Zulu build 9.0.1.3+11, mixed mode)

As you can see Java 9 is installed and ready to work. If you want to switch default Java’s version use command sdk default java <version>, but you can also switch version only for current terminal session using sdk use java <version>. It’s very convenient, if you want to check, how your code would behave on different Java version.

Summary

SDKMAN! is an essential tool for developers using Java, Groovy or any other JVM language. Check it out and you will not be disappointed.