Oracle Java on Windows
I recently downloaded an early access release of JDK 9 (build 68) for my Windows 7-based laptop. Because this is an early release, I was not surprised when the automatic installation introduced some less than ideal issues with the main Java Runtime Environment (JRE) installation on my laptop. After playing with the JDK 9 features that I wanted to try out, I downloaded the latest Oracle JDK 8 (Update 45) and used the automatic installer to install that. While still in that session, everything worked well.
When I powered up the laptop and logged in the next morning, my Java runtime environment was not healthy. The problem traced to specification of C:\ProgramData\Oracle\Java\javapath\java.exe
as the first entry in my Path
environment variable. When I changed directories to see the contents of the C:\ProgramData\Oracle\Java\javapath
directory, I saw the following:
This screen snapshot indicates that the java.exe
, javaw.exe
, and javaws.exe
entries in the C:\ProgramData\Oracle\Java\javapath\
directory are actually symbolic links (<SYMLINK>
) to similarly named executables in the JRE 9 installation.
The next screen snapshot shows the effect of this on my Java runtime environment:
The message is very clear on what the issue is: “The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe.” The reason that the system is looking for that is because the C:\ProgramData\Oracle\Java\javapath\
directory is the first entry in the Path
and the symbolic links in that directory point to a JRE 9 directory that doesn’t exist (I only have the JDK 9 directory):
StackOverflow user shpeley provides a nice overview of this situation and how he/she solved it. As I did, shpeley found that the automatic installer did not update these symbolic links when moving back versions (in shpeley’s case, from JDK 8 to JDK 7). Borrowing from shpeley’s solution (convenient because the syntax for making symbolic links in DOS is provided), I ran the following commands in the C:\ProgramData\Oracle\Java\javapath\
directory:
mklink java.exe "C:\Program Files\Java\jdk1.8.0_45\bin\java.exe" mklink javaw.exe "C:\Program Files\Java\jdk1.8.0_45\bin\javaw.exe" mklink javaws.exe "C:\Program Files\Java\jdk1.8.0_45\bin\javaws.exe"
The Oracle JDK/JRE installation on Windows normally goes very smoothly and, at most, I typically only need to change my %JAVA_HOME%
environment variable to point to the new directory (when upgrading the JDK). However, when things occassionally don’t go as smoothly, it’s helpful to be aware of the directory C:\ProgramData\Oracle\Java\javapath\
and its symbolic links. In (fortunately rare) cases, it may even be necessary to change these symbolic links.
Reference: | Oracle Java on Windows from our JCG partner Dustin Marx at the Inspired by Actual Events blog. |