paint-brush
Using SDKMAN To Manage Java Versionsby@harrison_brock
16,228 reads
16,228 reads

Using SDKMAN To Manage Java Versions

by Harrison BrockJanuary 23rd, 2019
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

<strong>What Is SDKMAN?</strong>

Company Mentioned

Mention Thumbnail
featured image - Using SDKMAN To Manage Java Versions
Harrison Brock HackerNoon profile picture

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:

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

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)







========================================11.0.2-open11.0.1-open10.0.2-open10.0.1-open9.0.4-open8.0.201-oracle

Install Java

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

$ sdk install java 11.0.2-open

Let’s also install Java 8 using this command:

$ sdk install java 8.0.201-oracle

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):

Using java version 11.0.2-open

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:

$ skd default java 8.0.201-oracle

This will display this:

Default java version set to 8.0.201-oracle

Uninstall a Java Version

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

sdk uninstall java 8.0.201-oracle

This will display this:

Uninstalling java 8.0.201-oracle

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.

Originally published at FluentJava.com on January 20, 2019.