Java programming language is one of the legends in the field of appllication software development.
As we know there are many JDK(java development kit ) developed by different company to meet the standard of any developer.
Imagine the pain of editing environment variables each time when your want your application to use a particular JDk version.
SDKMAN(software development kit Manager) now come in a your hero.Majorly it supports the linux ana Macos distribution.
But how is it for Windows developer who want to manage different version of JDK(java development kit ).
here is the steps to follow:
- 2.install git for windows 3.install 7zip for windows 4.run git as andministrator 5.copy the following command to git bash
run sdkma istallation command
Having SDKMAN! ready, I went on using it to install some Java SDKs. First the latest version of Java 17 Temurin:
$ sdk install java 17.0.8.1-tem
Even bash completion worked, which was helpful to find the correct name of the required version and distribution.
SDKMAN! asked if this version should be the default (active when a new shell is opened), to which I agreed.
When the installation was finished I checked the Java version:
$ java -version
openjdk version „17.0.8.1“ 2023-08-24
OpenJDK Runtime Environment Temurin-17.0.8.1+1 (build 17.0.8.1+1)
OpenJDK 64-Bit Server VM Temurin-17.0.8.1+1 (build 17.0.8.1+1, mixed mode, sharing)
$ echo $JAVA_HOME
/c/Users/devmachine/.sdkman/candidates/java/17.0.8.1-tem
Time to install another SDK (Java 11 Temurin):
$ sdk install java 11.0.20.1-tem
To switch to this version, I executed the following command:
$ sdk use java 11.0.20.1-tem
The bash completion worked here, too, offering only the already installed Java SDKs. So I just had to type up to the „11“, the rest of the SDK name being completed automatically after pressing TAB.
Checking if Java 11 is now active:
$ java -version
openjdk version „11.0.20.1“ 2023-08-24
OpenJDK Runtime Environment Temurin-11.0.20.1+1 (build 11.0.20.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.20.1+1 (build 11.0.20.1+1, mixed mode)
$ echo $JAVA_HOME
/c/Users/devmachine/.sdkman/candidates/java/11.0.20.1-tem
Using SDKMAN! with Java release candidates
It is not possible with SDKMAN! to install Java versions that are not yet officially released. However you can use SDKMAN! anyway to switch to such versions after having installed them manually.
Since the official release of Java 21 was only a few days away from the publishing date of this blog post, I wanted to have a look at its features.
Therefore I downloaded the release candidate for Windows/x64 from the OpenJDK site for Java 21, saved it under C:\Users\devmachine.sdkman\candidates\java\ and unzipped it:
$ unzip openjdk-21_windows-x64_bin.zip
To get a name that better suits the SDKMAN! naming conventions, I renamed the resulting folder:
$ mv jdk-21 21.rc-openjdk
Now when running the command sdk list java, I found the following entry at the bottom of the list:
================================================================================
Vendor | Use | Version | Dist | Status | Identifier
… (list of all other available versions)
Unclassified | | 21.rc | none | local only | 21.rc-openjdk
Using the known command, I was now able to switch to the OpenJDK 21 RC version:
$ sdk use java 21.rc-openjdk
Again, I could use bash completion to select the desired version, typing only up to the „21“ and pressing TAB. Checking the result:
$ java -version
openjdk version „21“ 2023-09-19
OpenJDK Runtime Environment (build 21+35-2513)
OpenJDK 64-Bit Server VM (build 21+35-2513, mixed mode, sharing)
$ echo $JAVA_HOME
/c/Users/devmachine/.sdkman/candidates/java/21-rc-openjdk
Conclusion
SDKMAN! is a great tool I never want to miss anymore. And the good news is that it works for Windows, too, and it even can be used to switch to unreleased Java Versions (except the installation part).
Top comments (0)