|

Exploring SDKMAN: A Versatile Tool for Java Developers

In the Java ecosystem, managing different versions of various software development kits (SDKs) can be a daunting task. This is where SDKMAN! steps in, offering a versatile solution to the problem. SDKMAN! is a software development kit manager that simplifies the installation, management, and switching between different versions of SDKs for Java Virtual Machine (JVM)

What is SDKMAN?

SDKMAN! is an open-source tool that allows you to manage parallel versions of multiple Software Development Kits on most Unix-based systems. It provides a convenient command-line interface to install, switch, remove and list Candidates. It’s a handy tool for Java developers, as well as developers working with other JVM languages like Groovy, Scala, and Kotlin.

Key Features of SDKMAN

  1. Easy Installation: With SDKMAN!, you can easily install different versions of various SDKs just by using a simple command in the terminal.
  2. Switching Between SDK Versions: SDKMAN! allows you to easily switch between different versions of an SDK. You can have multiple versions of an SDK installed and switch between them as needed.
  3. Wide Range of SDKs: SDKMAN! provides support for a wide range of SDKs, including but not limited to Java, Scala, Groovy, Kotlin, Gradle, Maven, and many others.
  4. Version Management: SDKMAN! helps manage and maintain different versions of SDKs. It also informs you about the latest stable releases of your installed SDKs.
  5. Environment Specific Configuration: With SDKMAN!, you can set specific versions of SDKs to be the default for different shell sessions.
  6. CPU Architecture Detection : SDKMAN! automatically detects your CPU architecture ( x86_64 or ARM64) and installs the software that matches your system architecture. e.g If you are installing JDK software on Apple MacBooks with M series(ARM) processors then it will install ARM version of JDK.

How to Install SDKMAN!

Installing SDKMAN! is a straightforward process. You can install it by simply executing the following command in your terminal:

curl -s "https://get.sdkman.io" | bashCode language: Java (java)
...
Set version to 5.16.0 ...
Set native version to 0.0.15 ...
Attempt update of interactive bash profile on regular UNIX...
Attempt update of zsh profile...



All done!


You are subscribed to the STABLE channel.

Please open a new terminal, or run the following in the existing one:

    source "/home/suresh/.sdkman/bin/sdkman-init.sh"

Then issue the following command:

    sdk help

Enjoy!!!
Code language: Java (java)

Then, open a new terminal or enter:

source "$HOME/.sdkman/bin/sdkman-init.sh"Code language: Java (java)

To check if the installation was successful, you can use the following command:

sdk versionCode language: Java (java)

If the installation is successful, this command will output the version of your SDKMAN.

sdkman 5.16.0Code language: Java (java)

Using SDKMAN

SDKMAN! is incredibly easy to use. For instance, to install a specific version of Java, you can use the following command:

Installing Java

Next let’s install Java using SDKMan

Following command lists all the JDK’s that can be installed

sdk list java Code language: Java (java)

The above command show lists like below.

================================================================================
Available Java Versions for Linux ARM 64bit
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 AdoptOpenJDK  |     | 8.0.275+1.hs | adpt    |            | 8.0.275+1.hs-adpt   
               |     | 8.0.252.hs   | adpt    |            | 8.0.252.hs-adpt     
 Corretto      |     | 19           | amzn    |            | 19-amzn             
               |     | 19.0.1       | amzn    |            | 19.0.1-amzn         
               |     | 17.0.5       | amzn    |            | 17.0.5-amzn         
               |     | 17.0.4       | amzn    |            | 17.0.4-amzn         
               |     | 11.0.17      | amzn    |            | 11.0.17-amzn        
               |     | 11.0.16      | amzn    |            | 11.0.16-amzn        
               |     | 8.0.352      | amzn    |            | 8.0.352-amzn        
               |     | 8.0.342      | amzn    |            | 8.0.342-amzn        
 Dragonwell    |     | 17.0.5       | albba   |            | 17.0.5-albba        
               |     | 17.0.4       | albba   |            | 17.0.4-albba        
               |     | 11.0.17      | albba   |            | 11.0.17-albba       
               |     | 11.0.16      | albba   |            | 11.0.16-albba       
               |     | 8.0.352      | albba   |            | 8.0.352-albba       
               |     | 8.0.345      | albba   |            | 8.0.345-albba       
 GraalVM       |     | 22.3.r19     | grl     |            | 22.3.r19-grl        
               |     | 22.3.r17     | grl     |            | 22.3.r17-grl        
               |     | 22.3.r11     | grl     |            | 22.3.r11-grl        
               |     | 22.2.r17     | grl     |            | 22.2.r17-grl        
               |     | 22.2.r11     | grl     |            | 22.2.r11-grl        
               |     | 22.1.0.r17   | grl     |            | 22.1.0.r17-grl      
               |     | 22.1.0.r11   | grl     |            | 22.1.0.r11-grl      
               |     | 22.0.0.2.r17 | grl     |            | 22.0.0.2.r17-grl    
               |     | 22.0.0.2.r11 | grl     |            | 22.0.0.2.r11-grl    
               |     | 21.3.3.r17   | grl     |            | 21.3.3.r17-grl      
               |     | 21.3.3.r11   | grl     |            | 21.3.3.r11-grl      
               |     | 21.3.3.1.r17 | grl     |            | 21.3.3.1.r17-grl    
               |     | 21.3.3.1.r11 | grl     |            | 21.3.3.1.r11-grl    
               |     | 21.3.2.r17   | grl     |            | 21.3.2.r17-grl      
               |     | 21.3.2.r11   | grl     |            | 21.3.2.r11-grl      
 Java.net      |     | 20.ea.26     | open    |            | 20.ea.26-open       
               |     | 20.ea.25     | open    |            | 20.ea.25-open       
               |     | 20.ea.24     | open    |            | 20.ea.24-open       
               |     | 20.ea.23     | open    |            | 20.ea.23-open       
               |     | 20.ea.22     | open    |            | 20.ea.22-open       
               |     | 19           | open    |            | 19-open             
               |     | 19.0.1       | open    |            | 19.0.1-open         
               |     | 11.0.12      | open    |            | 11.0.12-open        
               |     | 8.0.302      | open    |            | 8.0.302-open        
 Liberica      |     | 19.fx        | librca  |            | 19.fx-librca        
               |     | 19.0.1.fx    | librca  |            | 19.0.1.fx-librca    
               |     | 19.0.1       | librca  |            | 19.0.1-librca 
.....  Code language: Java (java)

Using identifier shown in above table, we can install the required JDK’s

The generic command to install java is

sdk install java <identifier>Code language: Java (java)

Let’s install the GraalVM Java 17 and 11 versions

sdk install java 22.3.r17-grCode language: Java (java)
Downloading: java 22.3.r17-grl

In progress...

#####################################################################       Code language: Java (java)

You can verify the installed Java versions by running the below command .

The status column indicates the installed status

sdk list java Code language: Java (java)
================================================================================
Available Java Versions for Linux ARM 64bit
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 AdoptOpenJDK  |     | 8.0.275+1.hs | adpt    |            | 8.0.275+1.hs-adpt   
               |     | 8.0.252.hs   | adpt    |            | 8.0.252.hs-adpt     
 Corretto      |     | 19           | amzn    |            | 19-amzn             
               |     | 19.0.1       | amzn    |            | 19.0.1-amzn         
               |     | 17.0.5       | amzn    |            | 17.0.5-amzn         
               |     | 17.0.4       | amzn    |            | 17.0.4-amzn         
               |     | 11.0.17      | amzn    |            | 11.0.17-amzn        
               |     | 11.0.16      | amzn    |            | 11.0.16-amzn        
               |     | 8.0.352      | amzn    |            | 8.0.352-amzn        
               |     | 8.0.342      | amzn    |            | 8.0.342-amzn        
 Dragonwell    |     | 17.0.5       | albba   |            | 17.0.5-albba        
               |     | 17.0.4       | albba   |            | 17.0.4-albba        
               |     | 11.0.17      | albba   |            | 11.0.17-albba       
               |     | 11.0.16      | albba   |            | 11.0.16-albba       
               |     | 8.0.352      | albba   |            | 8.0.352-albba       
               |     | 8.0.345      | albba   |            | 8.0.345-albba       
 GraalVM       |     | 22.3.r19     | grl     |            | 22.3.r19-grl        
               | >>> | 22.3.r17     | grl     | installed  | 22.3.r17-grl        
               |     | 22.3.r11     | grl     | installed  | 22.3.r11-grl        
               |     | 22.2.r17     | grl     |            | 22.2.r17-grl        
               |     | 22.2.r11     | grl     |            | 22.2.r11-grl        
               |     | 22.1.0.r17   | grl     |            | 22.1.0.r17-grl      
               |     | 22.1.0.r11   | grl     |            | 22.1.0.r11-grl      
               |     | 22.0.0.2.r17 | grl     |            | 22.0.0.2.r17-grl    
               |     | 22.0.0.2.r11 | grl     |            | 22.0.0.2.r11-grl    
               |     | 21.3.3.r17   | grl     |            | 21.3.3.r17-grl      
               |     | 21.3.3.r11   | grl     |            | 21.3.3.r11-grl      
               |     | 21.3.3.1.r17 | grl     |            | 21.3.3.1.r17-grl    
               |     | 21.3.3.1.r11 | grl     |            | 21.3.3.1.r11-grl    
               |     | 21.3.2.r17   | grl     |            | 21.3.2.r17-grl      
               |     | 21.3.2.r11   | grl     |            | 21.3.2.r11-grl      
 Java.net      |     | 20.ea.26     | open    |            | 20.ea.26-open       
               |     | 20.ea.25     | open    |            | 20.ea.25-open       
               |     | 20.ea.24     | open    |            | 20.ea.24-open       
               |     | 20.ea.23     | open    |            | 20.ea.23-open       
               |     | 20.ea.22     | open    |            | 20.ea.22-open       
               |     | 19           | open    |            | 19-open             
               |     | 19.0.1       | open    |            | 19.0.1-open         
               |     | 11.0.12      | open    |            | 11.0.12-open        
               |     | 8.0.302      | open    |            | 8.0.302-open        
 Liberica      |     | 19.fx        | librca  |            | 19.fx-librca        
               |     | 19.0.1.fx    | librca  |            | 19.0.1.fx-librca    
               |     | 19.0.1       | librca  |            | 19.0.1-librca       
               |     | 19           | librca  |            | 19-librca           
               |     | 17.0.5.fx    | librca  |            | 17.0.5.fx-librca    
               |     | 17.0.5       | librca  |            | 17.0.5-librca  Code language: Java (java)

Knowing current version of Java

sdk current java
Code language: Java (java)
Using java version 22.3.r17-grlCode language: Java (java)

Switching default version of Java

sdk default java 22.3.r11-grlCode language: Java (java)
Default java version set to 22.3.r11-grl
Code language: Java (java)

Checking the current version of Java after changing default java version

sdk current javaCode language: Java (java)
Default java version set to 22.3.r11-grl
Code language: Java (java)

Installing the Maven

You can list available Maven version with following command

sdk list mavenCode language: Java (java)
================================================================================
Available Maven Versions
================================================================================
     3.8.6               3.3.3                                                  
     3.8.5               3.3.1                                                  
     3.8.4               3.2.5                                                  
     3.8.3               3.2.3                                                  
     3.8.2               3.2.2                                                  
     3.8.1               3.2.1                                                  
     3.6.3               3.1.1                                                  
     3.6.2               3.1.0                                                  
     3.6.1               3.0.5                                                  
     3.6.0               3.0.4                                                  
     3.5.4                                                                      
     3.5.3                                                                      
     3.5.2                                                                      
     3.5.0                                                                      
     3.3.9                                                                      

================================================================================
+ - local version
* - installed
> - currently in use
Code language: Java (java)

Install required Maven version

sdk install maven 3.8.6Code language: Java (java)

Check the Maven installation

mvn --version Code language: Java (java)

If you see the error message like below

Command 'mvn' not found, but can be installed with:
sudo apt install maven
Code language: Java (java)

Run the command to make installed maven, default version

sdk default maven 3.8.6Code language: Java (java)

sdk install java 11.0.3.hs-adptCode language: Java (java)

To switch between installed versions, you can use the following command:

sdk use java 8.0.202.hs-adptCode language: Java (java)

Not just JDK and Maven there are huge number of SDD’s you can install using SDKMAN just from your commandline. You can view the complete list of SDK’s/Software that can be installed with SDKMAN here

Conclusion

SDKMAN! is a powerful tool that every JVM developer should consider integrating into their toolkit. It simplifies the management of different versions of multiple SDKs, making it indispensable in an environment where such tasks are frequently required. Now that you know what SDKMAN! is and how to use it, you are equipped to streamline your SDK management process and focus more on what truly matters – writing quality code.

Similar Posts