Having trouble in keeping multiple versions of Java in your single system? You have approached at the right place for seeking the solution.
In this blog, we will learn how to keep multiple versions of java in your system and how to switch between them as per your convenience.
Before moving forward, let’s have a basic understanding of what is SDKMAN?
What is SDKMAN?
As the official document says, “SDKMAN! is a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems. It provides a convenient Command Line Interface (CLI) and API for installing, switching, removing and listing Candidates.”
This is what we need in order to tackle this issue. For installing SDKMAN, you can refer to this link. Once you are done installing it, you can continue with this blog.
Steps for installing and switching between multpiles versions of java :
1.The command below will list down all the versions of java which are available. :
sdk list java
The symbol * in the below screenshot signifies all the versions of java which are installed on your system. Further, the symbol > signifies the current java version in use. The screenshot specifies that the system contains two versions : 11.0.2-open and 8.0.201-oracle and currently 11.0.2-open version is in use.
2. Install latest stable version of java using :
sdk install java
You can specify the version of java you want to install, for example, if your version is 9.0.1-zulu,
sdk install java 9.0.1-zulu
3. After installation, your system might contain multiple versions. You can switch between them using the command given below. For example if your required version is 8.0.201-oracle,
sdk use java 8.0.201-oracle
You can verify by using the command mentioned in step (1).
Now, you can continue working with your required version.