0

I have jdk6 and jdk7 installed on my Windows 8 machine. The JAVA_HOME environment variable originally pointed to C:\Program Files\Java\jre7.

I am now trying to run a program under Java 1.6. I changed JAVA_HOME to C:\Program Files\Java\jre6 but when I type java -version at the command prompt I get "java version "1.7.0_25". I have even deleted all environment variables related to Java and modified the path variable to not include any reference to Java. However, when I type java -version (which should fail) I get "java version "1.7.0_25".

I have also tried changing JAVA_HOME to "C:\Program Files\Java\jdk1.6.0_45" and java -versio still gives me "java version "1.7.0_25".

Does anyone know why I am unable to change the Java version to 1.6?

My current path is:

c:\Program Files (x86)\Intel\iCLS Client\;c:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Windows Live\Shared;%JAVA_HOME%\bin;%M2_HOME%\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;%OPEN_SSL%\bin
10
  • did you close and re-open the command prompt between changing the values? Commented Mar 6, 2014 at 14:31
  • Shouldn't this question be on superuser.com ? Commented Mar 6, 2014 at 14:33
  • Yes, I have tried a restart and a hard shutdown and reboot. Commented Mar 6, 2014 at 14:35
  • You should also ensure that %JAVA_HOME%\bin is in your PATH before any other Java bin folder. Commented Mar 6, 2014 at 14:35
  • @meyerjp3 - is there a java.exe in system32 ? try renaming it out of the way or placing java on the path before system32, or maybe paste the definition pf PATH on your machine here Commented Mar 6, 2014 at 14:36

2 Answers 2

2

Put JAVA_HOME variable before %SystemRoot%\system32 one. Windows installer adds java.exe file to Windows\system32 directory. And since it comes before JAVA_HOME, the executable from system32 is used.

(don't forget to restart console before checking again for java version)

Edit: last java adds to PATH folder C:\ProgramData\Oracle\Java\javapath. in my case it was on first position in PATH. That folder contains symlinks to java.exe javaw.exe and javaws.exe. Now you have two options.

  • you can delete C:\ProgramData\Oracle\Java\javapath and add JAVA_HOME (or point directly do java bin directory
  • you can change symlinks in C:\ProgramData\Oracle\Java\javapath to those pointing to right executables.
Sign up to request clarification or add additional context in comments.

Comments

1

In order to have the right JVM called from the terminal when you call java directly, you'll have to put %JAVA_HOME%/bin in your path before any other directory that may contain a java.exe implementation.

If you have installed a JVM using the Java installer, you may have a java.exe in your %SystemRoot%\system32. This one is just a dummy implementation that look at the registry and use the last JVM installed.

If you have a java.exe in your %SystemRoot%\system32 and it's not using the right JVM, you'll either have to correctly uninstall all JVM or to put %JAVA_HOME%\bin before %SystemRoot%\system32 in your path.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.