I've decided to not only write blogs but also small snippets, here comes the first one.
SDKMan is a tool to install, set and swap JDK.
SDKMan actually supports more than the Java JDK, among supported tooling is Java, Groovy, Scala, Kotlin and Ceylon. Ant, Gradle, Grails, Maven, SBT, Spark, Spring Boot, Vert.x and many others also supported.
It's written in Bash, only requires curl & zip/unzip.
So what SDKMan simplifies is
- Installation of different JDKs, Gradle versions and so on
- Swapping between JDKs
- Allowing local (by folder basis) JDK-versions
We start by installation
If you need a more detailed guide go to this page.
$ curl -s \"https://get.sdkman.io\" | bash
$ source \"$HOME/.sdkman/bin/sdkman-init.sh\"
$sdk version - should return something along
|Install JDK||Installs the latest stable version of Java JDK|
|Install specific version||Install scala 2.12.1|
|Install local version||Installs a JDK you have locally to the SDKMan. The version name must be unique!|
|List candidates||Lists all java candidates that are installable through SDKMan|
|Use version||Use the version said, this only changes the current shell|
|Default version||Changes version for all subsequent shells|
|Current version||Lists all currently selected versions|
Remember to point your JDK to the
./sdkman/candidates/java/current path. Do the same for your IDE, such as IntelliJ-IDEA.
I've got different projects where I need to use different java versions. In one project I need JDK 14 to include
jpackage and another one I'm forced to use JDK 8 (legacy system), to swap between these has never been simpler!
jEnv is a great alternative. According to some more JDK versions exists (haven't checked myself), but overall it seems that SDKMan is the preferred alternative.
Looking at GitHub one can clearly see that SDKMan is more popular, both by stars, latest commit and forks - which should be a decent enough to make a choice.
One thing I've learned both through work and my personal projects is that often it's better to make an non-optimal decision rather than trying to find the perfect solution, because diving into the pile of research to perfection will take much more time than just getting started.