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?
4 Answers 4
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.
1 Comment
Perhaps it finds have from inside the jre7 folder? You can check your PATH to see where it finds executables.
Comments
You have a jre7 so I assume it is update 51
Java takes the newest version by default.
Comments
It could also be if and where the JAVA_HOME ENV points to.
javacommand invokes the Java interpreter not the compiler so it would be found in a JRE package (i.e.jre7).javaccommand to compile. :)