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.

4
  • This shouldn't be a problem. Any code compiled with Java 1.6 can run on Java 1.8. Commented Sep 14, 2014 at 7:09
  • eventhough in path it is set to 1.6 but showing 1.8 from where it is picking 1.8 Commented Sep 14, 2014 at 7:12
  • refer this Commented Sep 14, 2014 at 7:21
  • You have both the 32bit and 64bit installations Commented Sep 14, 2014 at 7:22

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

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
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.