0

I am getiing java versions different with java command and javac command

java -version

java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode, sharing)

javac -version


javac -version
javac 1.6.0_18

where java

C:\Windows\System32\java.exe
C:\Program Files\Java\jdk1.6.0_18\bin\java.exe

path is set to 1.6 but it is picking 1.8 suggest me how to get this resolved.

a_horse_with_no_name
  • 440,273
  • 77
  • 685
  • 758
kavuru
  • 269
  • 3
  • 4
  • 13

1 Answers1

1

This is cause by the extremely annoying habit of the Java installer to copy java.exe andjavaw.exe to C:\Windows\System32\java.exe when you choose to install the "public jre" (but because that's the JRE, of course no javac.exe is copied).

And because System32 comes early in the PATH java.exe from there will be used (and before the regular JDK installation will no be searched for java.exe). But as there is no javac.exe in the JRE, that in turn is used from your JDK.

The public JRE is only needed for the browser Java plugin. In 2014 I consider the Java plugin to be dead and (I think) Oracle should change the JDK installer to not install that automatically.

Actually I consider this behaviour a bug to be honest. No installer should copy files to system32

a_horse_with_no_name
  • 440,273
  • 77
  • 685
  • 758
  • It is really anonying because even if you dont have version-x in your environment path it show you version-x because java.exe of version-x exists under C:\Windows\System32 – SparkOn Sep 14 '14 at 07:25
  • Note that what is copied to `system32` is just a stub and has no particular Java version. Which java it actually starts is governed by the "current Java version" setting in the Registry. – Marko Topolnik Sep 14 '14 at 08:47