1

Given

  • Multiple JDKs intalled in my Windows machine.. say JDK X, JDK Y,.. etc
  • Environment variables JAVA_HOME & PATH are pointing to JDK X.

Action

  • java -version at cmd, it printed JDK Y at console.

Expectation

  • want java -version to print JDK X

What am I missing, so that it should print JDK X ?

enter image description here

Aditya Rewari
  • 2,343
  • 2
  • 23
  • 36
  • Check if JAVA_HOME & PATH are pointing to correct location of JDK X. – kann Mar 02 '20 at 14:18
  • @kann Yes they are. Double checked this. Also, a mismatch here, i believe, would not had let me recognize java command at cmd – Aditya Rewari Mar 02 '20 at 14:20
  • Try `where java` on the command line to see which executable it picks. I think some common installs put a `java.exe` in `C:\Windows\System32` for some reason ... – Joachim Sauer Mar 02 '20 at 15:18
  • @JoachimSauer It returned me two location 1)C:\Program Files (x86)\Common Files\Oracle\Java\javapath 2) exe at Java Home path location – Aditya Rewari Mar 02 '20 at 15:24
  • @JoachimSauer location C:\Program Files (x86)\Common Files\Oracle\Java\javapath has 3 exe in it java, javaw, javaws – Aditya Rewari Mar 02 '20 at 15:25
  • Can you show your PATH variable? – Chris94 Mar 02 '20 at 15:58
  • @Chris94 It has just 'bin' appended to JAVA_HOME. – Aditya Rewari Mar 02 '20 at 16:02
  • @Chris94 JAVA_HOME points to the JDK X, as expected ! Check image above – Aditya Rewari Mar 02 '20 at 16:03
  • I meant your whole path. Have you checked it carefully for other java locations earlier in the path than this one? – Chris94 Mar 02 '20 at 16:05
  • What JDKs did you install? Oracle or OpenJDK or IBM? How did you install? Was it via an installer, i.e. an executable file? Or did you simply extract a ZIP file? In what order did you install your JDKs? Which did you install first, which second, etc. – Abra Mar 02 '20 at 18:03
  • @Abra It is Hotspot, through installer. jdk1.8.0_221 installed first. jdk1.8.0_161 installed recently – Aditya Rewari Mar 02 '20 at 18:21
  • The "Oracle" JDK appears first in your PATH. That is the one that will be used. – lit Mar 03 '20 at 01:46

0 Answers0