On Windows, the same java
executable 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 the the Windows\system32 C:\Program Files (x86)\Common Files\Oracle\Java\javapath
directory, and add that directory to the beginning of the PATH
variable.
If you don’t use a full path, the copy of java.exe
to run is found by using the PATH
system 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 javapath
entry with the version of Java you want in your PATH
system (not user) variable.