How to Fix – The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe

Are you trying to run a Java based application or program and getting an error – “The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe”?

It looks like the symlinks are not properly created when you’ve installed Java. When you install Java, it creates symlinks for java.exe, javaw.exe and javaws.exe under “C:\ProgramData\Oracle\Java\javapath\”.

If you do not find symlink folder “C:\ProgramData\Oracle\Java\javapath\” in your machine, you will get “The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe” error.

There are multiple options to fix this issue.

Update PATH variable with correct Symlink

It could be possible that your new installation changed the path of the “javapath” symlink. If the “javapath” symlink is not found under “C:\ProgramData\Oracle\Java\javapath\”, check it under “C:\Program Files (x86)\Common Files\Oracle\Java”, if found, update the PATH variable with “C:\Program Files (x86)\Common Files\Oracle\Java\javapath”.

Recreate the Symlinks

If you do not find “javapath” symlink under “C:\ProgramData\Oracle\Java\”, we’ll restore the symlink folder along with java.exe, javaw.exe and javaws.exe by executing below command:

mklink /d C:\ProgramData\Oracle\Java\javapath "C:\Program Files\Java\jdk1.8.0_271\bin\"

Update PATH variable with Correct Java Installation Path

If none of the above options work for you, you can try updating the PATH variable with the Java installation folder that you have it under “C:\Program Files\Java” and remove “C:\ProgramData\Oracle\Java\javapath\”.

If you don’t want to remove the “javapath” entry, at least make sure to that the correct Java path is on top of the list.

See also  How to convert char array to String

For example, “C:\Program Files\Java\jdk1.8.0_271\bin” is the Java Development Path you want to refer. Then you need to make sure that this path is on the top of the PATH list.

Frequently Asked Questions

How to add/update Java installation path under PATH environment variable list?

You can edit this PATH variable by following below steps:

  • On your Desktop, right click on “This PC” or “My Computer”
  • Select “Properties”, Control Panel will open
  • Select “Advanced system settings”, “System Properties” will open
  • Click on “Environment Variables” button, which is located at the bottom of “System Properties” dialog box
  • “Environment Variables” dialog box will open
  • Find “Path” variable under “System variables” section
  • Add or Update the correct Java bin PATH

Do I need to set JAVA_HOME?

If you are working on Java Development, then it would be better to set JAVA_HOME as environment variable under “System variables”. Some IDEs or Servers refer to Java development kit using JAVA_HOME variable. So, in the absence variable you might face issues starting the IDE or Server.