0

I've installed jdk 7 and set up the "JAVA_HOME" to this version. Then, I've installed jdk 6 and I've updated the "JAVA_HOME" to point to jdk 6. After closing and reopening the system, when typing "java -version", I got always :

java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode, sharing)

However, when typing

echo %JAVA_HOME%

I got :

C:\Program Files\Java\jdk1.6.0_45

I didn't understand why java -version don't display the value of "JAVA_HOME"

4
  • 1
    Check the PATH env.variable. That must be pointing to the old one... When you type java in the shell, the OS will try to find the executable. It looks in the current working directory, and then looks on the PATH... Commented Sep 18, 2013 at 13:52
  • which java will tell you which binary gets called. Commented Sep 18, 2013 at 13:54
  • I changed the PATH too to point to : C:\Program Files\Java\jdk1.6.0_45\bin Commented Sep 18, 2013 at 13:54
  • Resolved when putting the new value at the first of System PATH env variable . So when typing echo %PATH%, I get : C:\ProgramFiles\Java\jdk1.6.0_45\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.6.0_45\bin When it was set in user PATH env var, it's displayed at the end when typing eco %PATH%, as if it was overrided : C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.6.0_45\bin Commented Sep 18, 2013 at 14:17

5 Answers 5

2

Java 7 puts a java.exe in c:\windows\system32. You could try to delete these exe's, but I'm not sure Windows will allow it, or restore it after a reboot.

If you want to override it, you must put %JAVA_HOME%\bin as first entry in your PATH, before c:\windows\system32.

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

Comments

0

Which java starts when you run java -version depends on the PATH env variable, not JAVA_HOME. OS will be looking for java.exe (Windows) like for any other program

2 Comments

PATH is set to jdk 1.6. When typing echo %PATH%, I get : C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.6.0_45\bin
Resolved when putting the new value at the first of System PATH env variable . So when typing echo %PATH%, I get : C:\ProgramFiles\Java\jdk1.6.0_45\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\S‌​ystem32\Wbem. When it was set in user PATH env var, it's displayed at the end when typing eco %PATH%, as if it was overrided : C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.6.0_45\bin
0

if you run java on your command window, it takes java from the PATH variable. JAVA_HOME is used my maven etc...

3 Comments

thanks for info, but PATH is set to jdk 1.6. When typing echo %PATH%, I get : C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.6.0_45\bin
Make sure java is not available in C:\WINDOWS\system32
Resolved when putting the new value at the first of System PATH env variable . So when typing echo %PATH%, I get : C:\ProgramFiles\Java\jdk1.6.0_45\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\S‌​‌​ystem32\Wbem. When it was set in user PATH env var, it's displayed at the end when typing eco %PATH%, as if it was overrided : C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.6.0_45\bin
0

I believe your PATH variable is pointing to JAVA version 1.7.0_40/bin directory.

3 Comments

PATH is set to jdk 1.6. When typing echo %PATH%, Iget : C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.6.0_45\bin
@have u re-launched the console after changing your PATH variable
Resolved when putting the new value at the first of System PATH env variable . So when typing echo %PATH%, I get : C:\ProgramFiles\Java\jdk1.6.0_45\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\S‌​‌​ystem32\Wbem. When it was set in user PATH env var, it's displayed at the end when typing eco %PATH%, as if it was overrided : C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.6.0_45\bin
0

According to my understanding, this is nothing to do with your JAVA_HOME environment variable. You are getting java version from C:\windows\system32\java.exe.

If you don’t want that behaviour then in system variables section put %JAVA_HOME%\bin as starting element (Of course you should have JAVA_HOME). (I thought of adding image but I dont have enough reputation to do so :( )

Comments

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.