Using SDKMAN To Manage Java Versions

By Harrison Brock / January 20, 2019

What Is SDKMAN?

As Java developers, we have to work with different versions of Java from project to project. Installing different versions by hand and setting the PATH can become a real pain at times. SDKMAN is a command line tool that allows you to install different versions of Java, Gradle, Maven and more. SDKMAN also takes care of setting environment variables for you.

Installing SDKMAN

SDKMAN can be installed on Linux and Mac based system. To install SDKMAN enter this command at the terminal:

After installation is complete close the terminal and open a new terminal.

Check SDKMAN Version

To check the current SDKMAN version enter this command at the terminal:

This will display the current version:

Update SDKMAN

To update SDKMAN enter this command at the terminal:

List Available Version Of Java

To display the versions of Java, you can install enter this command at the terminal:

This will display a list of Java versions (I’m not going to list them all here)

Install Java

Let’s say you want to install Java 11.0.0-open enter this command at the terminal:

Let’s also install Java 8 using this command:

Display Current Java Version

To display the current version of Java in use enter this command at the terminal:

This will display this (you may have a different version):

Switching Between Java Versions

Currently, in the example, we are using Java 11.0.2-open, and we want to switch to Java 8.0.210-oracle. To do this enter this command at the terminal:

This will display this:

Uninstall a Java Version

Here we will uninstall Java 8. Enter this command at the terminal:

This will display this:

Conclusion

In the blog post, you learned how to use SDKMAN to install different versions of Java, switch between versions of Java, and uninstalling versions of Java. You can use these same methods to deal with installing tools like Maven, Gradle and so on.

About the author

Harrison Brock