简体   繁体   中英

Java: System cannot find the file C:\ ... java.exe

I have installed Java 8 and set my JAVA_HOME and JRE_HOME paths and added %JAVA_HOME% to the start of the path variable.

I created a helloworld.java application and am able to compile it using:

javac helloworld.java

However, when I try to run:

java helloworld

I get the error:

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

How can I solve this?

1.Just go to C:\\ProgramData\\Oracle\\Java\\javapath\\

2.You will find there shortcuts for java.exe,javaw.exe,javaws.exe which are pointing to a location where they actually are not existing now

3.Go to the jre location where you have installed java like C:\\Program Files\\Java\\jre6\\bin

  1. You will find java.exe,javaw.exe,javaws.exe

  2. Create shortcuts for these files and replace with the ones which are present in C:\\ProgramData\\Oracle\\Java\\javapath.

It works

只需将 %JAVA_HOME% /bin 设置为您的路径变量。

If you are blocked from modifying system variables from command line, but are able to open up an elevated command prompt, then run a command like this:

setx \\M JAVA_HOME "C:\\Program Files\\Java\\jdk1.8.0_25"

But of course, change the directory to point to your installed version of java. Note that the JAVA_HOME path does not point into the bin directory, it stops one level above bin.

I was able to solve this issue. To do so I used the advice from this answer :

Java SE Development Kit 8u25 on a 64-bit Windows 8

Set the following user environment variables (== environment variables of type user variables)

•JAVA_HOME : C:\Program Files\Java\jdk1.8.0_25
•JDK_HOME  : %JAVA_HOME%
•JRE_HOME  : %JAVA_HOME%\jre
•CLASSPATH : .;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
•PATH      : your-unique-entries;%JAVA_HOME%\bin 

(make sure that the longish your-unique-entries does not contain any other references to another Java installation folder.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM