In the next article we are going to take a look at SDLMAN. If you are a developer who often installs and test applications in different SDK, you have to try SDKMAN. This is one CLI tool which helps you easily manage various software development kits.
The tool is going to provide us with an easy way to install, change, list and remove SDK. With SDKMAN, we can manage parallel versions of multiple SDKs easily on any Unix-like operating system. It also allows developers to install Software Development Kits for JVM, Groovy, Scala, Kotlin, and Ceylon. Ant, Gradle, Grails, Maven, SBT, Spark, Spring Boot, Vert.x, and many others. SDKMAN is free, lightweight, open source and written in bash.
Install SDKMAN
Installing SDKMAN is very simple. First, we will have to make sure have installed the zip, unzip and curl applications. These are available in the default repositories for most Gnu / Linux distributions. In Ubuntu, we will only have to type in the terminal (Ctrl + Alt + T):
sudo apt install zip unzip curl
Now we will install SDKMAN using command:
curl -s "https://get.sdkman.io" | bash
Installation is that simple. Once it is complete, we will execute the following command:
source "$HOME/.sdkman/bin/sdkman-init.sh"
Finally, check if the installation is successful using the command:
sdk version
Manage multiple software development kits
To view the list of available candidates (SDK), run in terminal (Ctrl + Alt + T):
sdk list
As you can see, SDKMAN lists the candidates along with their description, their official website, and the installation command. Press the j key to go down in the list and the letter k to go up.
Install an SDK
To install a SDK, for example Java JDK, run:
sdk install java
If you have multiple SDKs, it will ask if you want the latest installed version to be set as the default. If you answer Si the version you just installed will be set as the default.
Install a version of an SDK
For install a particular version of an SDK, we will do something like the following:
sdk install ant 1.10.1
The above command will install Apacha Ant version 1.10.1. To list available versions of a candidate, ant in this case, use the command:
sdk list ant
As I said, if you have installed multiple versions, SDKMAN will ask you if you want the version you install to be set as the default. You can answer Yes to set this version as the default. Also, you can do this later using the following command:
sdk default ant 1.10.1
The above command will set Apache Ant version 1.10.1 as the default.
Check which version is in use
For check which version of an SDK is currently in use, for example Java, we will execute a command like:
sdk current java
Check the version of packages installed with SDKMAN
We can check which version is currently in use for all candidates that we have installed, we will execute the command:
sdk current
Update candidate
For update an outdated sdk, in this case scala, do it with the command:
sdk upgrade scala
As well we can check if any of the installed SDKs are out of date using command:
sdk upgrade
Enable or disable offline function
SDKMAN has an offline mode that allows SDKMAN to work when working offline. It can be enabled or disabled at any time using the following commands:
sdk offline enable sdk offline disable
Remove an installed SDK
To remove an installed SDK, run:
sdk uninstall ant 1.10.1
The above command will uninstall Apache Ant 1.10.1 from our system.
Update SDKMAN
In case there is a new version of SDKMAN, the following command installs it if available.
sdk selfupdate
SDKMAN will also check for updates periodically and will provide instructions for the update.
Clear cache
Recommended clear the cache It contains the SDK binary files downloaded from time to time. To do so, simply run:
sdk flush archives
It's also good clean temp folder to save space:
sdk flush temp
Uninstall SDKMAN
If after trying it you realize that you don't need SDKMAN or you don't quite like it, you can delete it by typing in the terminal:
rm -rf ~/.sdkman
Finally, open your .bashrc, .bash_profile and / or .profile files. Find and delete the following lines from the end of the file.
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! export SDKMAN_DIR="/home/entreunosyceros/.sdkman" [[ -s "/home/entreunosyceros/.sdkman/bin/sdkman-init.sh" ]] && source "/home/entreunosyceros/.sdkman/bin/sdkman-init.sh"
Help
For get more details, you can consult the help section by typing:
sdk help
For get more information about this program, you can consult the project website or your page GitHub.