Java -version shows old version of java
Asked Answered
Q

6

5

I have JDK 1.7_51 and JRE 1.7.79 update. My JAVA_HOME is set to C:\Program Files\Java\jdk1.7.0_51 and JRE_HOME is set to C:\Program Files\Java\jre7(update 79) and PATH points to JDK 1.7_51/bin.

Why does the java -version doesn't point to the java 7 79 update? it points java 7 update 51. It should ideally point to the JRE update 79.

Quiroz answered 11/7, 2015 at 0:40 Comment(1)
R
2

When you type in command prompt java it searches the PATH env variable and the first result it hits - returns. Since you pointed the PATH to JDK 1.7_51 - that's what you're getting.

JAVA_HOME environment variable is defined as an agreed protocol for applications that uses Java. It does not apply when you type in command prompt java -version (or java + any other switch).

Recessional answered 11/7, 2015 at 0:45 Comment(3)
when i had java 8, my java_home still pointed to C:\Program Files\Java\jdk1.7.0_51 with jre_home pointing to java 8. that time java -version did return me the java 8 version. trying to understand why thid would happen?Quiroz
my PATH variable still points to C:\Program Files\Java\jdk1.7.0_51\bin;Quiroz
@Quiroz it's not easy to remotely debug your env :) the PATH is usually very long - go over it and see if the installation of Java8 didn't add it to the PATH as well!Recessional
R
3

Uninstall the old version of java and try to reinstall new version of java.. i think that will help you

Roulette answered 25/1, 2019 at 6:54 Comment(0)
R
2

When you type in command prompt java it searches the PATH env variable and the first result it hits - returns. Since you pointed the PATH to JDK 1.7_51 - that's what you're getting.

JAVA_HOME environment variable is defined as an agreed protocol for applications that uses Java. It does not apply when you type in command prompt java -version (or java + any other switch).

Recessional answered 11/7, 2015 at 0:45 Comment(3)
when i had java 8, my java_home still pointed to C:\Program Files\Java\jdk1.7.0_51 with jre_home pointing to java 8. that time java -version did return me the java 8 version. trying to understand why thid would happen?Quiroz
my PATH variable still points to C:\Program Files\Java\jdk1.7.0_51\bin;Quiroz
@Quiroz it's not easy to remotely debug your env :) the PATH is usually very long - go over it and see if the installation of Java8 didn't add it to the PATH as well!Recessional
G
2

For Windows 10: 1) Open Command prompt

2) Type "where java" - Check all paths that are mentioned in the output

3) Go to environment variables -> PATH variable -> Edit -> Ensure that the the version you want to point to is in the list above all other paths.

4) Close the existing terminal, and open a new command prompt.

5) Type "where java" - Check all paths that are mentioned in the output, now your mentioned version path has to be the first in the output.

enter image description here

Goddamned answered 17/4, 2018 at 13:0 Comment(0)
B
0

You have to put the correct java Path in first place in you PATH variable environment, java es trying to execute the java from c:\windows\system32 first.

Bewick answered 11/7, 2015 at 2:15 Comment(0)
S
0

Try changing your %JAVA_HOME% to the new installation directory and make all attempts to uninstall all previous java installations.

If you're unsure of how to do this, search for "Edit system environment variables" and that's where you'll find environment variables.

Sigmatism answered 11/7, 2015 at 3:35 Comment(0)
E
0

delete java.exe,javaaws.exe,javaw.exe from C:\Windows\system32 folder. and retry jave -version. It will show the newly updated version in the environment variables

Ebberta answered 25/1, 2019 at 6:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.