• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Clean Programmer

Clean Programmer

Programming & DevOps Resources

  • Home
  • About
  • Contact

SDKMAN! Managing SDKs Were Never So Smart

May 21, 2018 Monzurul Haque Shimul

If you’re working on multiple java projects, it is very common to switch between different java versions. I face this too often. We have a number of projects running in production which need different java version. Sometimes we need to fix issues or to add a customer required feature in older projects. These older projects require java version 6 or 7, while newer projects require java 8 or 9. So it is often required to switch between them during development.

There are many different ways to switch between java versions, most of them are dependent on different OS environments i.e. macOS, Linux, Windows etc. Below are some examples how to do the switching.

For ubuntu/debian linux:

$ sudo update-alternatives — config java

For redhat/fedora:

$ su
$ /usr/sbin/alternatives — config java
$ /usr/sbin/alternatives — config javac

For macOS:

$ /usr/libexec/java_home -v

When you work in multiple OS environments, i.e work in a server machine (linux) or in a desktop/laptop (macOS/ubuntu/windows), it is a problem to remember all these commands. So, is there any easier way to solve this problem?

Here comes SDKMAN! The Software Development Kit Manager. SDKMAN! is a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems. It provides a convenient Command Line Interface (CLI) and API for installing, switching, removing and listing Candidates.

  • SDKMAN! is for making life easier for developers. No more trawling download pages, extracting archives, messing with _HOME and PATH environment variables.
  • It is written in bash and only requires curl and zip/unzip to be present on your system.
  • It runs on any UNIX based platforms: Mac OSX, Linux, Cygwin, Solaris and FreeBSD. A Powershell CLI version is available for Windows users.
  • It allows to manage multiple versions of each candidate.

Installation:

To install this amazing tool, simply open a new terminal and enter:

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

Follow the instructions on-screen to complete installation.

Usage:

It currently supports Ant, Gradle, Grails, Groovy, Java, Kotlin, Maven, sbt, Scala, Spark, Spring Boot, VisualVM and many more.
To list all the available candidates:

$ sdk list

Install the latest stable version of your SDK of choice (say, Java JDK) by running the following command:

$ sdk install java

Need a specific version of an SDK? Simply qualify the version you require:

$ sdk install java 9.0.4-oracle

Listing all available candidates for java:

$ sdk list java

================================================================================
Available Java Versions
================================================================================
     9.0.7-zulu                                                                    
   + 9.0.4-oracle                                                                  
     9.0.4-openjdk                                                                 
     8.0.172-zulu                                                                  
 > * 8.0.171-oracle                                                                
     7.0.181-zulu                                                                  
   + 7                                                                             
     10.0.1-zulu                                                                   
     10.0.1-oracle                                                                 
     10.0.0-openjdk                                                                
                                                                                   
                                                                                   
                                                                                   
                                                                                   
                                                                                   

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

When having multiple versions installed, to see the current version in use, run:

$ sdk current java

To switch the java version for the current terminal, run:

$ sdk use java 8.0.171-oracle

If you want to set a specific version as default for all terminals, run:

$ sdk default java 8.0.171-oracle

Now no matter what is your operating system is, you can easily switch between your SDK version running a common command.

For more detail about SDKMAN! go visit the official site here.

Summary

I must have to say, SDKMAN! is a must have tool for all software developers to make life easier managing different SDK versions. Give it a try. You will love it.

Related Posts

Mapping Between Domain & Data Transfer Objects With MapStruct
Mapping Between Domain & Data Transfer Objects With MapStruct
Adding 3rd Party Jar to a Maven Project
Practicing Java: Simple String Encoding and Decoding
Practicing Java: Simple String Encoding and Decoding

Categories: Java, Java EE, Uncategorized Tags: java, jdk, maven, sdk, sdkman

Primary Sidebar

Categories

  • Apache Kafka
  • Druid
  • Git
  • Java
  • Java EE
  • Redis
  • Spring
  • Uncategorized
  • Weblogic
  • Wildfly

Featured Posts

Generating Fibonacci sequence using Java Stream API

Getting Unique Counts from Druid Using HyperLogLog

How to setup Apache Kafka Cluster

Deploy applications to a remote WildFly Server using jboss-cli-client.jar

How to configure JMS in WildFly

How to Reindex Data in Druid with Native Batch Ingestion

Footer

Monzurul Haque Shimul

I’m a full-stack software engineer with 10 years of experience in design and development of large scaled Enterprise Software Systems built on Java and Java EE related tools and technologies. I’m also a contributor on GitHub, Stack Overflow, DZone. My core expertise lies in building JVM-based, scalable, reactive, data-driven applications.

Follow

  • Email
  • GitHub
  • LinkedIn
  • Twitter

© 2019 CLEAN PROGRAMMER

  • Home
  • Archive
  • About
  • Contact
  • Privacy Policy
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OKNoRead more
Revoke Cookies