In this article, we are going to talk a little about  SDKMAN! How it is installed and what it offers us. We will also see a real example of installing various versions of Java using this tool. Keep reading!

What is SDKMAN!?

SDKMAN! is a tool that allows us to manage the installation and configuration of various versions of SDKs (Software Development Kits) through the command line. Initially, it was known as GVM (Groovy Environment Manager) and was inspired by other tools used by the Ruby community.

We sometimes come across applications that work and must compile their SDK in very different versions as developers. For example, from Java 1.8, 11, later, earlier, etc. The same thing happens to us with Maven and other SDKs. Every time we want to change the version, it becomes tedious to search, download, install and configure our operating system to use this recently installed version. For this, we have at our disposal applications such as SDKMAN!.

Firstly As a curiosity, I am passing you the repository where the SDKMAN project is located! You can see it is a set of script shells.

Features of SDKMAN!

  • Focused on JVM JDKs: Java, Groovy, Scala, Kotlin and Ceylon. Ant, Gradle, Grails, Maven, SBT, Spark, Spring Boot, Vert.
  • Light as it is by linear commands.
  • Multi-platform
  • Open Source with Apache 2.0 license.

Installing SDKMAN! on Windows

Its website provides us with a straightforward installation for Linux and Mac, but we will install it on our Windows 11.

The installation in Windows presents us with an initial problem, and that is that it is done with a bash script. We have used the GitBash console that was installed together with  Git for the installation.

Once this code snippet has been commented out, we can install it using the command :

bash skin

Example of how to use SDKMAN!

Once we have installed the SDKMAN! We can install different versions of SDKs in our system through our terminal. Next, we will illustrate examples of installing various versions of Java.

SDK list java

Through this command, we can view a list of all the versions of the Java JDK that we have installed, the ones that we have configured by default, the ones that we can install, etc. As shown in the following image:

View with SDKMAN!  the list of versions of JDK of Java that we have installed.

To install/uninstall/change use or change the one we will use by default, we will use the identifier from the Identifier column. We note that we currently have 11.0.12 open from Java.net installed by default. If we wanted to switch to Amazon’s 8.322.06.1, we would have to perform the following command:

$ SDK use java 8.322. 06 . 1 -amzn

I am using java version 8.322. 06 . 1 -amzn in this shell.

We have the option to use this console by default or by default.

As indicated, all this can be done for Java, Kotlin, Groovy, Maven, Scala and a long list of SDKs provided by this tool. Next, I include links to the SDKMAN portal! in which we can see all the JDKs and SDKs that they offer us, as well as more examples of using the commands:

  • JDKs: https://sdkman.io/jdks
  • SDKs: https://sdkman.io/sdks
  • Usage examples: https://sdkman.io/usage

Configuring our IDE and environment variables

Once installed, SDKMAN!. We must configure our Windows environment variables (if we want to use it in the console) or the SDK path of our IDE to point to the folder where SDKMAN selects the current version!

~/.sdkman/candidates/java/current

For each SDK that SDKMAN! has installed, we will have several folders with the versions and a folder called current, where the understanding that we have configured as current is located.

If we use the path to this current for the Windows environment variable or our IDE, every time we change the current version by console, we will have our console and our IDEs pulling the version that we have determined by the console in SDKMAN! This is the great advantage that SDKMAN provides us!: by means of command, we can jump from one version of the SDK to another fast and straightforward way.

NVM, alternative for Node.js

Therefore, Like SDKMAN!, for developments in Node.js,  NVM (Node Version Manager) allows switching between different versions of Node.

conclusion

Above all, In this article, we have dissected SDKMAN! A powerful tool to install and configure various versions of SDKs via the command line. Thus, we have seen what it consists of, its main features, how to install it and an example of how to install various versions of Java with it.