2

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?

rni902
  • 287
  • 1
  • 4
  • 9

4 Answers4

5

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

Atul Pundir
  • 59
  • 1
  • 2
3

Just set %JAVA_HOME%/bin to your path variable.

hab
  • 118
  • 1
  • 9
  • Obviously you work with Windows. Be sure to exit and restart your console after configuring the path in your system properties. - Do you like to give us your path (set path)? – hab Oct 26 '15 at 22:27
  • Thank you I have solved the issue now. I had set the JDK_HOME and JRE_HOME vars to the wrong path. I have included an answer stating the paths that I used. – rni902 Oct 27 '15 at 08:51
0

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.

Janac Meena
  • 1,929
  • 20
  • 22
-1

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.)

Community
  • 1
  • 1
rni902
  • 287
  • 1
  • 4
  • 9