JAVA_HOME and java -version

Be sure not to mix the system variable path and the user variable system path. I feel OK in calling java without the absolute path (when I know how JAVA_HOME and PATH are configured).


For me the issue was in my PATH variable, C:\ProgramData\Oracle\Java\javapath; was added by java windows install before my %JAVA_HOME%\bin;. So I'd echo %JAVA_HOME% pointing to a JDK7 and java -version showing jdk8.

I'd to put %JAVA_HOME%\bin; before C:\ProgramData\Oracle\Java\javapath; so that java -version displays jdk7.


Try %JAVA_HOME%\bin\java -version

If you modify JAVA_HOME, it's usually better to invoke java with an absolute path (using JAVA_HOME) because the new binary is probably not in the path (and then Windows will load the wrong binary).


Make sure that the PATH environment variable is pointing to %JAVA_HOME%\bin.