SDKMAN - best JVM manager
JVM ecosystem
When you are dealing with Big Data tools, then surely you need to use JVM of some sort. Installation of the JVM on a Linux machine is a straightforward process. Just install, export JAVA_HOME, and you are good to go.
Technically it is true, but what if you need to manage more Java versions at once? Or maybe you need to install additional JVM languages or tools. Add to this a fresh virtual machine for each new PoC (Proof of Concept) of the new project, and you can see where I’m going.
For this issue, I present a great solution - SDKMAN. It is a tool for managing JDK and other JVM tools and languages.
SDKMAN Instalation
To install SDKMAN just type in the terminal:
curl -s "https://get.sdkman.io" | bash
After that open new shell or just run source ~/.bashrc
. It is that simple!
Installing JDKs
Now let’s install JDK 8 and JDK 11. For starters lets type:
sdk list java
You should see a similar table. In this case, I trimmed the table to be smaller to fit on the page. In reality, there are many more versions of JDK to choose from.
================================================================================
Available Java Versions
================================================================================
Vendor | Use | Version | Dist | Status | Identifier
--------------------------------------------------------------------------------
AdoptOpenJDK | | 14.0.2.j9 | adpt | | 14.0.2.j9-adpt
| | 14.0.2.hs | adpt | | 14.0.2.hs-adpt
| | 13.0.2.j9 | adpt | | 13.0.2.j9-adpt
| | 13.0.2.hs | adpt | | 13.0.2.hs-adpt
| | 12.0.2.j9 | adpt | | 12.0.2.j9-adpt
| | 12.0.2.hs | adpt | | 12.0.2.hs-adpt
| >>> | 11.0.8.j9 | adpt | | 11.0.8.j9-adpt
| | 11.0.8.hs | adpt | | 11.0.8.hs-adpt
| | 8.0.265.j9 | adpt | | 8.0.265.j9-adpt
| | 8.0.265.hs | adpt | | 8.0.265.hs-adpt
| | 8.0.252.j9 | adpt | | 8.0.252.j9-adpt
Amazon | | 11.0.8 | amzn | | 11.0.8-amzn
| | 8.0.265 | amzn | | 8.0.265-amzn
Azul Zulu | | 14.0.2 | zulu | | 14.0.2-zulu
================================================================================
I recommend installing JVM from AdoptOpenJDK. Just type (the last part is taken from column Identifier):
sdk install java 8.0.265.hs-adpt
And for JDK 11 type:
sdk install java 11.0.8.hs-adpt
Managing JDKs
Let’s see installed versions using: sdk list java | grep installed
. The >>>
means a version in use.
We can change the selected version by using following command:
sdk use java <tag>
where <tag>
is a version identifier (from the output of sdk list java
) like 8.0.265.hs-adpt
.
But use
changes only the JVM for the current shell. If we want to make a global change, type:
sdk default java <tag>
Let’s try this:
sdk default java 8.0.265.hs-adpt
echo $JAVA_HOME
java -version
As we can see, it easy to change the JVM version. Cool!
Installing Scala and sbt
Let’s say you are using Apache Spark or Apache Flink for your Big Data project. For this, you may use Scala, a great mix of a functional and object-oriented language. The standard Scala build tool is the sbt (like Maven or Gradle). If we want to install them, just use the SDKMAN!
Let’s see available Scala and sbt versions:
sdk list scala
sdk list sbt
We can install as many Scala and sbt versions as we like and change them as we did with the JDKs. So let’s install Scala 2.11 and 2.13 and newest sbt.
sdk install scala 2.13.3
sdk install scala 2.11.12
sdk install sbt 1.3.13
And that is it! With a single tool, we can see what is available, we can install what we need and even easily swap the versions. Such a great tool!
Check out SDKMAN site
Go to sdkman.io/ and see what other SDKs and JDKs you can download.