JavaBeginner
JavaBeginner

Reputation: 551

"The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe"

I am on JDK 8u25 on Windows 8, and I am experiencing a problem with my Java installation. I can run javac perfectly fine, but running java produces this error message:

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

How do I fix this?


I think the problem has to do with my environment variables.

The important variables, as I have set them, are:

And their expansions, as viewed with set in cmd, are:

The full output of set can be viewed here.

Upvotes: 55

Views: 208839

Answers (22)

user2603432
user2603432

Reputation:

I've got a similar problem I'm currently working on solving. I can't say this will solve your error since there may be issues with other software (which is my case with Eclipse Luna).

Java is using the path given in your PATH variable, which is,

  C:\ProgramData\Oracle\Java\javapath

Go to this folder (ProgramData is hidden, so unhide it if necessary) and right click on the java.exe symlink. You'll see in the Target field where it's looking for java.exe. It may be pointing to the java.exe file from your previous jdk1.6.0_45 install. Either paste in new shortcuts here or change the PATH setting as others have mentioned.

I've found that the Java installer doesn't change the javapath or update the system path, at least when going from 1.8 to 1.7. In my case changing the shortcuts only led to a problem with Eclipse on startup.

EDIT:----- After playing with javapath folder shortcuts it turns out you need symlinks, at least for Eclipse. See, Windows how to create directory symlink.

You don't need the /d switch for a file symlink,

  cd C:\ProgramData\Oracle\Java\javapath 

  mklink java.exe "C:\Program Files\Java\jdk1.8.0_20\bin\java.exe"
  mklink javaw.exe "C:\Program Files\Java\jdk1.8.0_20\bin\javaw.exe"
  mklink javaws.exe "C:\Program Files\Java\jdk1.8.0_20\bin\javaws.exe"

This now works for me.

Upvotes: 56

Harnek
Harnek

Reputation: 1

Faced the same issue while upgrading to OpenJDK17 from JDK8 and got this error while executing Java -version in cmd.

Fix: goto path C:\Program Files\Java\jdk-17\bin copy files java.exe and javaw.exe, goto path C:\ProgramData\Oracle\Java\javapath and delete the existing shortcuts( I had java 8 before this and shortcuts were placed to java.exe, javaw.exe & javaws.exe.) and paste these two files there.

Upvotes: -1

eScape CS
eScape CS

Reputation: 43

For me it worked like this: On your desktop go to Search->View advanced system settings->Environment Variables Under System Variables look for path and click Edit. Click on New and add the new Path and move it to the top. To find your java path if you don't know where it is installed in cmd type where javac

Upvotes: 0

Mahmoud Gado
Mahmoud Gado

Reputation: 1

This will solve all problems relating to Java and environment variables:

Make your way to Windows' Environment Variables dialog. Under System variables, select the variable named Path. Click Edit... Remove the entry that looks like:

C:\ProgramData\Oracle\Java\javapath Add the path of your JDK/JRE's bin folder.

Don't forget to set JAVA_HOME.

This helped me.......:-)

Upvotes: 0

Mike
Mike

Reputation: 1

<>\Common Files\Oracle\Java\javapath\ is now created as a junction, no symlinks anymore

Upvotes: -1

Abhigna
Abhigna

Reputation: 1

For New version of Java JavaPath folder is located

64 bit OS

"C:\Program Files \Common Files\Oracle\Java\javapath\"

X86

"C:\Program Files(x86) \Common Files\Oracle\Java\javapath\"

Upvotes: 0

Gowtham Epparla
Gowtham Epparla

Reputation: 1

Please remove "C:\ProgramData\Oracle\Java\javapath\java.exe" from the Path variable and add your jdk bin path. It will work.

In my case the I have removed the the above path and added my JDK path which is "C:\Program Files\Java\jdk1.8.0_221\bin"

Upvotes: 0

Hari Tyagi
Hari Tyagi

Reputation: 51

I got same error while running JAVA command. To resolve this, I moved the java path as the first entry in the path, and it resolved the issue. Please have look at this screenshot for reference:

enter image description here

Upvotes: 5

Jitesh Beniwal
Jitesh Beniwal

Reputation: 108

This will solve all problems relating to Java and environment variables:

  1. Make your way to Windows' Environment Variables dialog.
  2. Under System variables, select the variable named Path. Click Edit...
  3. Remove the entry that looks like:

    C:\ProgramData\Oracle\Java\javapath
    
  4. Add the path of your JDK/JRE's bin folder.

  5. Don't forget to set JAVA_HOME.

Upvotes: 8

Amit
Amit

Reputation: 151

I had in PATH:

C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Java\jdk1.8.0_92\bin;<others omitted>

I removed:

C:\ProgramData\Oracle\Java\javapath;

and that fixed the issue for me. java -version now gives details about the Java version, etc.

Upvotes: 15

Abhishek D K
Abhishek D K

Reputation: 2425

Don't worry. Just uninstall jdk as well as jdk updates Before re installing jdk ,delete the oracle folder inside programData hidden folder in C:\ Then reinstall. Set the following,

JAVA_HOME
CLASSPATH
PATH
JRE_HOME ( is optional)

Upvotes: 0

Vandana Manhas
Vandana Manhas

Reputation: 361

This problem exists when you upgrade from one version to another.because jdk is not automatically upgraded.

For the same you can change the environmental varibles. In system variables look for the PATH and add the jdk bin location in the front of the string(not at the back). Once you have done that check in CMD if "java" and "javac" works. if it works, again go to system variables. add "CLASSPATH" A the variable and set value " . c:\Program Files\Java\jdk1.8.0_91\lib;"

Upvotes: 1

Martin Carr
Martin Carr

Reputation: 1

c:\ProgramData\Java\javapath is used for symlinks. You can of course add the full path to your Java Path to %PATH%, but equally you can create a symlink to the path to the above location.

  1. Open CMD as Administrator.
  2. Type mklink java.exe (full path to your Java.exe) eg

mklink java.exe "C:\Program Files\Java\jdk1.8.0_25\bin\java.exe"

Upvotes: 0

Eshwarya
Eshwarya

Reputation: 29

  1. Uninstall all JDKs installed on your computer from the Java Control Panel
  2. Search for C:\ProgramData\Oracle\Java and delete that directory and all files contained within. You can do this from the command line using rmdir /S C:\ProgramData\Oracle\Java
  3. Then search for C:\ProgramData\Oracle and delete the oracle folder. You can do this using rmdir /S C:\ProgramData\Oracle
  4. Now install JDK and set the path.

  5. Run the program.You won't find the same problem anymore.

Upvotes: 2

Rajat
Rajat

Reputation: 11

This usually happens when you update the java, the easiest way to solve this is to just uninstall the JDK & then reinstall it. NOTE: This doesnt remove the path or classpath so no need to worry.

Upvotes: 1

Vincent Risi
Vincent Risi

Reputation: 221

Why Oracle did such a poor way to point to java is beyond me. We solved this problem by creating a new link to the JDK

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

The same would work for a JRE if that is all that is required.

This replaces the old symlinks in C:\ProgramData\Oracle\Java\javapath (if they existed previously)

Upvotes: 22

roblogic
roblogic

Reputation: 1326

If you're on a corporate PC that's fairly restricted by group policy, this might work....

Assuming that

  1. your Windows PATH includes C:\ProgramData\Oracle\Java\javapath
  2. you have JDK installed to C:\Program Files\Java\jdk1.8.0_60\bin

Then create the following text file mklink.bat and put it on your desktop:

rem mklink.bat
mklink /d C:\ProgramData\Oracle\Java\javapath "C:\Program Files\Java\jdk1.8.0_60\bin"
pause

Now right-click it and choose "Run as Administrator". Provide admin credentials. The script should report success. Now you can compile or run Java.

Upvotes: 1

Murari Goswami
Murari Goswami

Reputation: 1

I had also similar problem where by I had to un-install JDK 1.8 and needed jdk 1.7. What i did was removed the symbolic links from the javapath and then imported the shortcuts of java, javaw, javaws from the bin directory to the javapath folder. However, I found some permission issues in the enterprise laptop where by I did not have the privilege to modify/ update this directory. I had given appropriate permission from the administrator and there by resolved it.

Upvotes: 0

john godfrey
john godfrey

Reputation: 1

I got the same after installing java8 from a non-permissioned account. To fix I simply reinstalled from admin user account. This created the quoted directory with file links to java exes.

Upvotes: 0

Farrukh Chishti
Farrukh Chishti

Reputation: 8467

There must be two or more PATH variables. Try merging all of them into one using semi-colon (;)

Upvotes: 0

Johny
Johny

Reputation: 2188

There are 2 versions of jdk in your PATH VARIABLE jdk1.6.0_45 and jdk1.8.0_25. Try removing the first one ie. jdk1.6.0_45 from the PATH

Upvotes: 1

Tnadev
Tnadev

Reputation: 10112

Updating the PATH Environment Variable

If you do not set the PATH variable, you need to specify the full path to the executable file every time you run it, such as:

C:\> "C:\Program Files\Java\jdk1.8.0\bin\javac" MyClass.java


It is useful to set the PATH variable permanently so it will persist after rebooting.
To set the PATH variable permanently, add the full path of the jdk1.8.0\bin directory to the PATH variable. Typically, this full path looks something like
C:\Program Files\Java\jdk1.8.0\bin.
Set the PATH variable as follows on Microsoft Windows:

  • Click Start, then Control Panel, then System.
  • Click Advanced, then Environment Variables.
  • Add the location of the bin folder of the JDK installation to the PATH variable in System Variables.
    The following is a typical value for the PATH variable:

    C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.8.0\bin

    Note:

  • The PATH environment variable is a series of directories separated by semicolons (;) and is not case-sensitive. Microsoft Windows looks for programs in the PATH directories in order, from left to right.

  • You should only have one bin directory for a JDK in the path at a time. Those following the first instance are ignored.

  • If you are not sure where to add the JDK path, append it.

The new path takes effect in each new command window you open after setting the PATH variable.

Upvotes: 2

Related Questions