I already had JDK 5 on my machine. I have updated JDK by installing Java Development Kit 7. Now, I have set the Path and JAVA_HOME variables as per latest Java. but still "java -version" showing me older version.

C:\>java -version
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode)

Please see the current states of my environment variables as below:

C:\>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.7.0_03\

C:\>echo %Path%
C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Barclays Capital\CommonApi\bin\
;C:\Program Files\Windows Imaging\;C:\WINNT\system32\WindowsPowerShell\v1.0;C:\Program Files\Citrix\ICAService\;C:\Program Files\Citrix\Syst
em32\;C:\Program Files\Perforce;C:\Program Files\Barclays Capital\P4CustomTools;C:\Program Files\Apache Software Foundation\apache-maven-3.0
.4\bin;C:\Program Files\Common Files\Adobe\AGL;C:\Apps\oracle\product\\client\bin;C:\Apps\oracle\product\10.2.0\client\BIN;C:\APPS\o
racle\client\\home1\bin;C:\WINNT\system32\;C:\WINNT\;C:\WINNT\system32\Wbem;C:\Program Files\Windows Imaging;C:\Program Files\Java\j

C:\>javac -version
javac 1.7.0_03

I know how to change the environment variable and I have referred other post on stack overflow.

What should be reason behind incorrect path returned by java -version command ?

migrated from stackoverflow.com Apr 12 '14 at 22:26

This question came from our site for professional and enthusiast programmers.

  • The java exe is in the JRE but the javac exe is in the JDK. Looks like your JRE is in the path before the JDK. – Java1 Feb 28 '14 at 7:39
  • Thanks ! I have given the whole Path in question. Can you please advise solution over this ? – Umesh Patil Feb 28 '14 at 7:44
  • update path and JAVA_HOME variable – Saint Feb 28 '14 at 7:45
  • Yes, put C:\Program Files\Java\jdk1.7.0_03\bin at the beginning of the path – Java1 Feb 28 '14 at 7:45

When installing a public JRE (used by the Java plugin), a java.exe file is also created in C:\WINNT\system32 (IIRC). It's probably this java command that is executed, since C:\WINNT\system32 comes before the JDK/bin directory in your PATH.

Put the JDK/bin directory at the beginning of the PATH.

  • Perfect ! This resolved my issue ! – Umesh Patil Feb 28 '14 at 7:47
  • Also to check order you can execute where java in command prompt – Patison Feb 28 '14 at 7:49
  • Is this windows command ? – Umesh Patil Feb 28 '14 at 7:51
  • yes. and which is an analog for linux – Patison Feb 28 '14 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.