Search code examples
javaversionjava-home

Java -version shows old version of java


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.


Solution

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