Streamline Your Java Development Workflow with SDKMAN
Tags: java, scala
Published: 2023-01-08 15:42:22

# Switching between Java versions can be as easy as running a single command

Do you have multiple versions of Java, Maven, Gradle, or other SDKs to manage? Are you tired of manually switching between different versions of these SDKs? SDKMAN to the rescue! SDKMAN is a command-line tool that allows you to quickly switch between various versions of SDKs, making it easier and more efficient to develop and test your applications. In this article, we'll discuss the benefits of using SDKMAN, provide some installation instructions, and explain how to use it to switch Java versions.

## Benefits of using SDKMAN
![Logo of SDKMAN](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t9w4hxifuamgfzfd0p8y.png)
SDKMAN is a great tool for developers because it makes it easier to manage and switch between different versions of Java. By default, you can only have one version of Java installed on your computer at a time. With SDKMAN, you can easily switch between different Java versions without needing to uninstall or reinstall Java every time.

Another great benefit of SDKMAN is that it also works out of the box for other SDKs in the JVM ecosystem, like Maven, Gradle, Scala and SBT. You don’t have to install a different manager for each SDK. 

In addition to that, SDKMAN makes it easier to keep your Java versions up-to-date. SDKMAN will automatically check for updates and notify you when new versions of Java are available. This saves you time and effort, as you don't need to manually search for updates

Finally, SDKMAN is a tool built in bash and is completely free to use. It's open-source and available for anyone to use.

## Installation
Installing SDKMAN is very easy. All you need to do is run the following command in your terminal:

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

If the command has been executed successfully, the output is going to look similar to this:
![Installation result of SDKMAN](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dd0qic35umtc9vg9khaj.png)

Once the command has been run, you can use SDKMAN to install and switch between different versions of Java. You might have to restart your Terminal before the `sdk` commands will work. To check whether SDKMAN works in your terminal after the installation, type the following command:

```bash
sdk version
```

It should be able to output the version of SDKMAN like this:

```bash
SDKMAN 5.16.0
```

## Installing Java versions

SDKMAN makes it very easy to install different Java versions. To list all available Java versions that you can install, simply run the following command:

```bash
sdk list java
```

This will list all the available versions of Java that you can install. If you want to install Java 11 from the vendor Temurin, you can look for the identifier in this list which is: 11.0.17-tem. Type `q` to exit the list. Using the identifier for the Java version you want to install, run the following installation command:

```bash
sdk install java 11.0.17-tem
```

After successfully installing Java 11, the output will look like this:
![Installation result for Java 11](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/doygko05dacfc55kxq90.png)

If you need to install Java 17 from Temurin, it’s as easy as copying the identifier from the output command of `sdk list java` and placing it in the sdk install command:

```bash
sdk install java 17.0.5-tem
```

## Switching Java versions

To switch between Java versions, you need to look for the identifier of your Java version in `sdk list java` and copy that value to switch to. If you’d like to switch to Java 11 of Temurin, run the following command:

```bash
sdk use java 11.0.17-tem
```

If you’d like to switch to Java 17 of Temurin, this would be the correct command:

```bash
sdk use java 17.0.5-tem
```

## Making a specific Java version the default

If you’d like to make a specific Java version the default, like version 17 of Temurin, you can run the following command:

```bash
sdk default java 17.0.5-tem
```

## How about Maven, Grade, and the rest?

We’ve seen how to install and switch between Java versions. But how would you know which SDKs are supported? No worries! The complete list of SDKs supported by SDKMAN can be found here: [https://sdkman.io/sdks](https://sdkman.io/sdks). How do you install and switch between other JVM-based SDKs like Maven, Grade, and the rest? The principle is the same for Java. You simply have to replace the Java and identifier command with the one the SDK you want to use:

```bash
sdk list maven
sdk install maven <version-identifier>
```

## Conclusion

SDKMAN streamlines the management of all the SDKs that you’d need in the JVM ecosystem. We’ve covered how to easily install and switch Java versions and also how to do that for other SDKs that you’d need. SDKMAN is definitely a tool worth checking out and can help you save time and effort in the process. This is especially helpful for teams that are working on multiple projects with different SDK version requirements. Happy coding! 😎

<hr />
If the content was helpful, feel free to support me [here](https://www.buymeacoffee.com/duncanlew):
<a href="https://www.buymeacoffee.com/duncanlew" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>