问题
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 set %JAVA_HOME%/bin to your path variable.
回答2:
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
You will find java.exe,javaw.exe,javaws.exe
Create shortcuts for these files and replace with the ones which are present in C:\ProgramData\Oracle\Java\javapath.
It works
回答3:
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.)
回答4:
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.
来源:https://stackoverflow.com/questions/33355440/java-system-cannot-find-the-file-c-java-exe