Thursday, July 2, 2015

Oracle Java on Windows: C:\ProgramData\Oracle\Java\javapath

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.

UPDATE: Ganesh's comment reminded me that it may be necessary to run Command Prompt (or Powershell) as Administrator to perform the operations discussed in this post. Two screen snapshots that follow demonstrate doing this in Windows 10. The first image shows right-clicking on "Command Prompt" and selecting "Run as administrator" and the second image shows what a Command Prompt window opened in that fashion looks like (in this case, it says "Administrator: Command Prompt" in the window's title bar rather than the normal "Command Prompt".


Robbie said...


Fadoua Nakhali said...

Many thanks !

kishore said...

hi what will happen after we execute the mklink command?
Does I need to keep the "c/prgoramdata/oracle/javapath" still?

@DustinMarx said...


It's been a while since I had to make this manual change, but my recollection is that I did leave the "javapath" string in the my PATH, but I ensured that my JAVA_HOME (which was defined to point to my JDK 8 installation) appeared first on the PATH before the "javapath" entry.


kishore said...

Very Good morning., Thank you for the early reply. I removed the "javapath" string and Still eclipse open fine for me.
One more problem is, Eclipse closing on a sudden with my intervention by leaving an error file in eclipse folder.

(As office holiday I could not able to post the entire content., Will post you on Monday. Meanwhile please have a look on the below.)
The main content of the file is:

"A fatal error has been detected by the Java Runtime Environment:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffeb23c7510, pid=7320, tid=9084

JRE version: Java(TM) SE Runtime Environment (8.0_11-b12) (build 1.8.0_11-b12)
Java VM: Java HotSpot(TM) 64-Bit Server VM (25.11-b03 mixed mode windows-amd64 compressed oops)

Failed to write core dump. Minidumps are not enabled by default on client versions of windows

@DustinMarx said...


I'm not familiar with that particular issue, but it looks similar to what apangin addresses in the StackOverflow thread JVM Crash - "EXCEPTION_ACCESS_VIOLATION" and is probably due to something like that (a d3d9.dll in this case).


Koacervate said...

thx, you made it easy to understand ;)

Shravya said...

Thanks a lot for posting this solution. It worked for me when I was trying to execute my java program on windows10 with latest jdk release.

Ganesh Desai said...

it is giving an error:
mklink java.exe "C:\Program Files\Java\jdk1.8.0_45\bin\java.exe"
You do not have sufficient privileges to perform this operation."

@DustinMarx said...


It sounds like you might need to run the operation as Administrator. One approach to doing this is to right-click on the "Command Prompt" icon and select "Run as administrator".

I'll add two screen snapshots to this effect to the original post.