Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

environment variables - "The system cannot find the file C:ProgramDataOracleJavajavapathjava.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:ProgramDataOracleJavajavapathjava.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:

  • JAVA_HOMEC:Program FilesJavajdk1.8.0_25
  • CLASSPATH.;%JAVA_HOME%lib
  • PATH<other paths omitted>;%JAVA_HOME%in

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

  • JAVA_HOMEC:Program FilesJavajdk1.8.0_25
  • CLASSPATH.;C:Program FilesJavajdk1.8.0_25lib;%CLASSPATH%;
  • PATHC:ProgramDataOracleJavajavapath;C:Program FilesJavajdk1.6.0_45in;<other paths omitted>;C:Program FilesJavajdk1.8.0_25in

The full output of set can be viewed here.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:ProgramDataOracleJavajavapath

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,

  mklink java.exe "C:Program FilesJavajdk1.8.0_20injava.exe"
  mklink javaw.exe "C:Program FilesJavajdk1.8.0_20injavaw.exe"
  mklink javaws.exe "C:Program FilesJavajdk1.8.0_20injavaws.exe"

This now works for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...