SDKMAN is a tool that lets you install and switch between different versions of SDKs for various languages and platforms on Unix systems.
It is inspired by apt, pip, RVM, and Git, and supports Java, Scala, Kotlin, Groovy, Ant, Gradle, Grails, Maven, SBT, Spark, Spring Boot, Vert.x, and more.
A] INSTALL GITBASH
install git bash
copy zip.exe and bzip2.dll from C:\Program Files (x86)\GnuWin32\bin to C:\Program Files\Git\mingw64\bin
reopen git-bash
B] INSTALL SDKMAN
Just launch a new terminal and type in:
$ curl -s "https://get.sdkman.io" | bash
Follow the on-screen instructions to wrap up the installation. Afterward, open a new terminal or run the following in the same shell:
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
Lastly, run the following snippet to confirm the installation's success:
$ sdk version
You should see the output containing the latest script and native versions:
SDKMAN!
script: 5.18.2
native: 0.4.3
C] INSTALL JDK 21
The usage of SDKMan helps you to manage different Java versions on your machine in a simple way, even the last one.
After installing the SDKMan, you should run:
sdk list java
Choose what Java 21 version you want to install, in this example, I will use 21.0.1-oracle
sdk install java 21.0.1-oracle
Then you can set the previous version as the default.
sdk default java 21.0.1-oracle
(Optional) Or only use that on your terminal
sdk use java 21.0.1-oracle
Now you can check the Java version in your environment:
java -version
You should see:
#java version "21.0.1" 2023-10-17 LTS
#Java(TM) SE Runtime Environment (build 21.0.1+12-LTS-29)
#Java HotSpot(TM) 64-Bit Server VM (build 21.0.1+12-LTS-29, #mixed mode, sharing)
(Optional) If not set your JAVA_HOME in your windows environment variables to 'C:\Program Files\Java\jdk-21'
More
👉 install on IntelliJ: https://dev.to/danilopdl/using-java-21-on-intellij-36mm
👉 Baeldung: https://www.baeldung.com/java-sdkman-intro