Search code examples
javajava-home

Which Java installation takes priority ? The one installed with msi extension or the one which is unzipped and added with JAVA_HOME, Path set?


I am using a RDP(Windows 10) machine. It has JDK 1.8.xxx already installed under program files and Java -version command returns 1.8.xxx some times, see below why !.

Then I downloaded the zip version of JDK 21 which is the latest LTS version and installed it by unzipping it and created JAVA_HOME, and added the bin folder to the path at the end.

I hoped the JDK 21 would be the effective. Yes and No. On random days, the Java -version command returns 1.8.xxx some times. and some days it returns 21.

I saw the Stack Over Flow question/answer at here already, but does not address my issue.


Solution

  • I have eliminated the dilemma for now, even though I did not get the satisfactory reason. I uninstalled the JDK 1.8.xxx, since it is a windows installed application and residing under program files, and appears under installed 'programs & features' list.

    This now resulted in leaving JAVA_HOME effective and returning 21 for 'java -version' command