Working with multiple versions

Working with multiple projects is challenging and even more when they use different versions of JDK, node, etc.

Just wanted to share a quick way to use multiple versions and switch easily.

Node multiple versions

Consider using NVM (node version manager)

Installation

Use the following cURL or Wget command which installs from an install script

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

Verify installation: nvm --version

Usage

Install latest version

To download, compile, and install the latest release of node, do this:

nvm install node "node" is an alias for the latest version

List all available node versions

nvm ls-remote

Install a particular version

nvm install v16.19.0

The current version is automatically set to the newly installed version.

You can verify installation using node --version

Switch to another installed version

You can list all installed versions using nvm ls or nvm list

To use a particular version nvm use v16.19.0

JDK Multiple Versions

Consider using SDKMAN

Installation

Paste the following command in a terminal

curl -s "https://get.sdkman.io" | bash

Usage

List all available JDK versions

sdk list java

Install a particular version

Take the value of the last column that corresponds to the java version

sdk install java 11.0.12-zulu

Verify installation by java -version

Switch to another installed version

You can list all installed versions using sdk list java

To use a particular version sdk use java 8.0.342-amzn (this would only apply to current terminal)

Make Default version

To make a particular java version as default.

sdk default java 11.0.12-zulu (this would apply to all terminals)