Due to different project requirements and updates, developers often end up having multiple installations of the Java Development Kit (JDK) on their machines. Managing these JDK installations is essential for a smooth development experience. In this blog post, we will discuss how to manage multiple JDK installations on Windows using Java Version Manager (JVMS) .
What is JVMS?
Java Version Manager (JVMS) is a lightweight command-line tool designed to manage multiple JDK installations installed on your machine. With JVMS, you can easily switch between different JDK versions and configure JAVA_HOME efficiently.
Step-by-Step Guide to Manage Multiple JDK Installations Using JVMS
- Download and Install JVMS:
Head over to the official GitHub repository of JVMS (https://github.com/ystyle/jvms/releases) and download the latest release. Extract the downloaded ZIP file and place it in a folder of your choice, preferably a location that is convenient for running the command-line tool.
- Set Environment Variable:
Add the extracted JVMS folder’s path to your system’s PATH environment variable so that you can access it from any directory.
Now open Windows Command prompt in administrative mode.
List Installed JDKs:
To list all installed JDKs on your machine, open a command prompt and run
ls .This command will display all discovered JDK installations.
> jvms ls or > jvms list Installed jdk (* marks in use): No installations recognized.Code language: Java (java)
Find available JDK’s for Download
To install JDK first we need to find out the all available JDK’s for download.
Run following command to find JVM’s available for download.
> jvms rls 1) 20.0.0 2) 17.0.6 3) amazon_jdk17.0.6 4) 11.0.8 5) amazon_jdk11.0.13_8 6) 1.8.0_151 7) amazon_jdk1.8.0_265 8) amazon_jdk1.8.0_222_x86 9) 1.8.0_74_x86 10) 1.7.0_67 use "jvm rls -a" show all the versions For a complete list, visit https://raw.githubusercontent.com/ystyle/jvms/new/jdkdlindex.jsonCode language: Java (java)
To install particular version of JDK use
> jvms install <version>Code language: Java (java)
<version> with the desired JDK version. (The version number should be from one of the entry listed from
jvms rls command
Once installed , you can verify with list command.
> jvms list * 1) 20.0.0Code language: Java (java)
Installing your own JDK
If you look at the list of JDK’s available for download with
jvms rls command, you are presented with very limited options.
But there is manual way to install your own choice of JDK distribution.
If you look at the folder structure, it contains download and store folders. ( there folders will be created once you download one version of JDK)
download– Folder where jvms downloads JDK
store – Folder where jvms installs the software
jvms/ └── jvms.exe └── download └── store └── jdk-18Code language: Java (java)
To install your choice of distribution, simply install/unpack the JDK into store folder.
If you have already installed JDK in your system, you can simply move the folder to store folder. The version will appear as installed JDK version.
>jvms list Installed jdk (* marks in use): * 1) jdk-18 2) graalvm-21 3) graalvm-17 4) 20.0.0Code language: Java (java)
The * mark denotes the current java version.
Switching between JDK’s
You can switch between different JDK with
>jvms switch <version>Code language: Java (java)
<version> with the desired JDK version you want to switch to. This command will update the JAVA_HOME environment variable and set it to the selected JDK installation.
>jvms switch graalvm-21 Switch success. Now using JDK graalvm-21Code language: Java (java)
You can verify the version being used
>java --version openjdk 21 2023-09-19 OpenJDK Runtime Environment GraalVM CE 21+35.1 (build 21+35-jvmci-23.1-b15) OpenJDK 64-Bit Server VM GraalVM CE 21+35.1 (build 21+35-jvmci-23.1-b15, mixed mode, sharing)Code language: Java (java)
>jvms list Installed jdk (* marks in use): 1) jdk-18 * 2) graalvm-21 3) graalvm-17 4) 20.0.0Code language: Java (java)
Removing Specific JDK
You can remove specific version of JDK with
> jvms remove <version>Code language: Java (java)
<version> with the desired JDK version you want to remove.
Managing multiple JDK installations on Windows is made easy with JVMS. With its simple command-line interface, you can quickly switch between JDK versions and maintain a smooth development environment for your Java applications.