How do I persuade Windows to use the JDK instead of a JRE?
This question has been asked before, here and elsewhere:
How do I set the default Java installation/runtime (Windows)?
The trouble is that Windows ignores JAVA_HOME and it also ignores the fact that I made the JDK bin directory the first entry in the path.
When I run java -version from the command line, instead of invoking my JDK 1.6 installation, it runs the 1.7 JRE.
My guess is that this is a problem specific to 1.7, and Windows 7 is doing something it shouldn’t with the registry.
Any ideas on how to fix this?
Edit: Oops. I wrote “first entry in the classpath” above, when I meant “path”. Sorry.
On Windows, the same
javaexecutable can load DLLs for different versions of Java. It looks at the directory from which it’s running to see if it contains libraries for a particular version of Java. If not, it uses the Windows Registry to locate the default version of Java for the system.The Java installer will put a copy of
java.exe(but no libraries) in thethe Windows\system32C:\Program Files (x86)\Common Files\Oracle\Java\javapathdirectory, and add that directory to the beginning of thePATHvariable.If you don’t use a full path, the copy of
java.exeto run is found by using thePATHsystem variable. Since this directory doesn’t contain the DLLs of a particular Java runtime version, one is located one by looking at the registry.So, you either need to modify the registry, or replace the
javapathentry with the version of Java you want in yourPATHsystem (not user) variable.