tun_eng
tun_eng

Reputation: 133

java -version doesn't display the value of JAVA_HOME

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"

Upvotes: 0

Views: 1435

Answers (5)

Seeta Ramayya Vadali
Seeta Ramayya Vadali

Reputation: 465

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 :( )

Upvotes: 0

GeertPt
GeertPt

Reputation: 17846

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.

Upvotes: 2

Juned Ahsan
Juned Ahsan

Reputation: 68715

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

Upvotes: 0

cremersstijn
cremersstijn

Reputation: 2395

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

Upvotes: 0

Evgeniy Dorofeev
Evgeniy Dorofeev

Reputation: 135992

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

Upvotes: 0

Related Questions