Buy @ Amazon

Switch Between Java Versions In Windows 10


There are 2 Options to manage multiple java versions in your windows: 
  • jEnv : I have used this for long in my Ubuntu/Mac laptops. This doesn't support Windows platform though!
  • SDKMan : This one has a workaround for Windows 10 platform (see https://sdkman.io/install) and that leaves me no choice but try this one out.

The SDKMan Way To Switch Between Java Versions in Windows 10


Some good things about SDKMan:
  • It supports all platforms Linux/Mac/Windows.
  • It is more popular tool over jEnv today, per libhunt.
  • It supports great deal of JDKs and SDKs for quick install and use.

Installing SDKMan in Windows has the following pre-requisites:
  1. Install ConEmu which is  an advanced console window (also known as local terminal emulator). This is only an emulator and hence shares the same environment as Windows. Alternatively, you can install CygWin, which is a more popular and pioneer tool in this Linux Terminal on Windows.
  2. If you have installed Git in Windows it is likely that you have installed Git Bash. If not, please do install Git Bash (that comes bundled with Git installer for windows) with all the default recommended options as the installer suggests.
  3. The SDKMan makes use of zip command for its installation. So you may need to install GnuWin Zip
  4. It may also use the following commands in its installation script, viz., zip, unzip, tar, gzip, curl. According to the SDKMan installation page, MinGW can be used to provide this tooling. But because, I use ConEmu out of personal preference, I had to check for the validity of the following commands in my ConEmu terminal like below:

When all the above commands showed the installation path of the softwares, we can be confident that the commands would work well to install SDKMan from within ConEmu.

Now from within ConEmu terminal, we can go ahead and run installation script for SDKMan like below:
    $ curl -s "https://get.sdkman.io" | bash

Next, open a new terminal or enter:
    $ source "$HOME/.sdkman/bin/sdkman-init.sh"

Lastly, run the following code snippet to ensure that installation succeeded:
$ sdk version

Bingo, you can now go ahead and install your favourite versions of java sdk, Ant, Maven, Groovy, Gradle, etc using your now favorite SDKMan :)

Quick Cheatsheet for SDKMan



References