Sitemap
kunalkrishna85

kunalkrishna85

java developer

Multiple JDK Installation : Best Practise

5 min readDec 2, 2025

--

Often as a developer one might have to install multiple versions of Java(JDK) and interchange between them depending on use case(Professional developement, trying latest JDK, experimenting with differnt vedors — oracle, Amazon Corretto, Red Hat).

Press enter or click to view image in full size
img 1 : A windows system showing two latest version (21,25) installed

You can install many java versions on a single system and depending on requirement you can select required version by simply changing Environment variables. In other words, env var is the controller

In this post, I intend to complile my understanding of several things one needs to keep in mind.

  • Terminal
  • Environment Variables - configuration & verification
  • JDK installation
  • IntelliJ idea

Terminal

The main commands for this context are

  • java --version : shows current java version recognized by system
    — javac --version : shows current compiler recognized by system
  • where java : location of installation of current java

Environment Variable

  • Windows reads Environment Variable Path list from Top to Bottom.
  • Stop fast : as soon as it finds the first match it stops finding another path.
  • System32 is almost always at the top of env variables meaning any installation in this path gets high priority.
  • After any fresh installation or adding new path variables, close System Properties tab to see effect of newly added paths.
img 2 :Reopen to see updated environment variables after every install
  • Althouth not tested but I would recommend in a similar way after deleting any env variable press ok and close this tab.

JDK Installation

  • Prefer installing LTS versions (21, 25)
  • Installation does three important things :
    — creates files in : C:\Program Files\Java\jdk-XX (XX= version e.g 21, 25) (img 3)
    — creates shortcuts of executables in : C:\Program Files\Common Files\Oracle\Java\javapath (img 4).
    — also adds this path on top in Environment VariablesSystem Path (img 6).
img 3

Before Java 8 :

Oracle JDK installer would put a copy of java.exe into a high priority folder C:\Windows\System32 . This made it messay and hard to manage multiple versions.

After Java 8+ (SymLink Era) :

Oracle stopped putting in System32. Instead they created a hidden folder : C:\Program Files\Common Files\Oracle\Java\javapath

Press enter or click to view image in full size
img 4 : SymLink

This folder contains “Symlink” (shortcut) pointing the latest JDK installation.

Press enter or click to view image in full size
img 5 : shortcuts(SymLink)

Note : Oracle installed forces this javapath folder to the very top of System Path

Press enter or click to view image in full size
img 6 :Oracle forces javapth to the top of System Path

Note : the last JDK you installed (JDK 25) overwrites the symlinks in that folder and takes over your terminal, regardless of what JAVA_HOME you set.

Get kunalkrishna85’s stories in your inbox

Join Medium for free to get updates from this writer.

So whenever you install a new JDK you will loose acess to older JDK installations. How to use older versions?

Press enter or click to view image in full size
img 7 : Terminal showing two installations

> To access a specific JDK , create env_variable for that older java version which you want to use.

Press enter or click to view image in full size
img 8 :

> Add this System Variable JAVA_HOME_21 inSystem Path : and place it below java 25 path.

Press enter or click to view image in full size
img 9 : the java version which you want to use should be at higher level than other java version path

To test java version close env variable setting winown and open a new terminal and type java -- version

Press enter or click to view image in full size
img 10 : java -- version to see check current version

You can have many more jdk installed and select to any . The only rule you need to remember is :

The java version which you want to use should be at higher level than other java version path in System Path .

Now let us see how to install 3rd java : openjdk-25.0.1

> Extract compressed file → this creates directory output openjdk-25.0.1_windows-x64_bin .

> Inside this lies jdk-25.0.1 . Copy this to your Java dir

> This directory contains the bin and therefore the path of this director needs to be added to system path inorder to make it usable.

img 11 : installing openJDK-25
Press enter or click to view image in full size
img 12 : adding sys path for openJDK-25

Now apply the rule in sys path — move this new variable to top.

Press enter or click to view image in full size

Test current version on, remember new, cmd : user java --versionor javac --version

Press enter or click to view image in full size

Note : when the first value in Path starts with %(except %SystemRoot%) the window open differently (No move up, move down button). To fix this see this.

Press enter or click to view image in full size

Fix : It is because it has % in it and it is not followed by SystemRoot. Windows recognizes variable Path having tompmost value starting with %AnyString as ordinary variable. Howerver, notable exception to this is $SystemRoot% which equals C:\WINDOWS . If you keep this on top, it still opens a detailed window. (This user reporeted from Win 11 experience)

Press enter or click to view image in full size
Full scree restored

IntelliJ Idea

InetelliJ allows to chose java version at project level. I will update more on this later.

Ctrl + Alt + Shit + S opens Project Structure settings.

Press enter or click to view image in full size

Pressing green + button allows to add any installed java. These added SDKs are ready to be attached to any project. This makes any project modular. Any project can be coupled with any java enviornement.

Now to chose Java for a project. Open the project in InjelliJ IDE and see on top right. There chose Edit Config`

Now chose suitable Java version :

--

--