Manage Your Java Versions with SDKMAN!

You can easily install and switch between Java versions using SDKMAN! It allows for setting a default version and switching to a specific version for a particular project.
How to get started
Ok, so how to get started? Well that’s easy. Just use the following command in your terminal to install SDKMAN!
curl -s "https://get.sdkman.io" | bashAfterwards open a new terminal or run the next command in the same shell:
source "~/.sdkman/bin/sdkman-init.sh"SDKMAN! supports installing versions of Java, Scala, Kotlin, Groovy, Gradle, Maven and Spring Boot. To install the latest stable Java version use:
sdk install javaYou can also list all available candidate versions using:
sdk list javaAnd install a specific version from the list with for example:
sdk install java 22.0.2-amznTo use a specific version in the current shell type:
sdk use java 21.0.3-temMake it the default version with the following command:
sdk default java 21.0.3-temEnv Command
You can create a config file .sdkmanrc that you can store in your repository:
sdk env initThen every time you work in that repository you can change to the specific version in the config file using:
sdk envAnd if you are lazy like me, you can even let the terminal do this automatically for you.
To make this happen set the sdkman_auto_env variable to true in ~/.sdkman/etc/config
The terminal also resets to your default version upon leaving the directory.
Upgrade versions
To see what is currently out of date you can use the following command:
sdk upgradeor
sdk upgrade javaTo install the latest version of SKDMAN! use:
sdk selfupdateFinally, you can refresh the list of candidate versions with:
sdk update