简体   繁体   中英

'java -version' command shows different version than what I have

In my C:\\Program files\\java folder I have three folders:

jdk1.6.0_45
jre6
jre7

However typing the command java -version in the command prompt gives the following output:

java version "1.7.0_51"

How does that make sense? I think it should have outputed jdk1.6.0_45 . How can this be explained?

Perhaps it finds have from inside the jre7 folder? You can check your PATH to see where it finds executables.

Already answered this in the comments thread but for future reference:

Broadly speaking, the JDK package determines the version of the Java compiler ( javac ) you have and the JRE package determines the version of the Java interpreter ( java ) you have.

The version that is run when you type java or javac in the command line is the version that is listed in your PATH environmental variable, which will generally point to the newest version from the newest package (the Java installer does this for you).

The JDK will install the corresponding JRE at the same time so you'll have the same version of java and javac by just installing the latest JDK.

You have a jre7 so I assume it is update 51

Java takes the newest version by default.

也可能是JAVA_HOME ENV指向的位置和位置。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM