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...


Unknown 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.

Unknown 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.


qweqweqwe said...

this page may help you that how to change your environment variables to use jdk.

Unknown said...


In my case, something else was needed:

After I followed your instructions (for downgrading the JRE from 1.8 to 1.7) and ran "java -version" command, the following error message appeared:

C:\Users\cljonov>java -version
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'

has value '1.8', but '1.7' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.

So, I opened regedit and change the requested value (HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion) from 1.8 to 1.7. After I ran again "java -version", voila!

C:\Users\cljonov>java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

Chrisco said...

The way the javapath is set up in Windows now is actually much closer to the way Java is set up in various Linux flavours - using symbolic links to make it easier to have a single point or reference to java that can then be easily upgraded to a newer java version without changing the path variable.

Unknown said...

Thanks, Neil Siao for the link to Douglas C. Ayers page. Doug's page solved the problem for me.

Now, after rebooting Windows 10 (64 bit), I correctly see the following from the DOS command line:

C:\WINDOWS\system32>java -version
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

C:\WINDOWS\system32>javac -version
javac 1.8.0_202

Thank you. It was preventing me from completing a tutorial in Java Spring (

Rate Hike said...

you may have to fool with the registry: