I'm having a problem when running programs that use Java from the command line. I get back a message saying Java.exe could not be found.
I've followed the instructions found in several places for setting JAVA_HOME in Windows 7.
As can be seen in the image I'm pointing to the JDK folder as instructed, I've also tried several variations including linking to the bin folder(where java.exe is located).
What am I doing wrong, and how can I debug this.
EDIT:
Typing Set in Command Prompt outputs
As many have mentioned I had to add...
...to the path variable.
However what was not mentioned and was stopping this from working was that I had to make sure java\bin directory is in the path statement before the windows\system32 directory, otherwise this will not work.
I was able to find the information here.
From the desktop, right click the Computer icon.
1. Choose Properties from the context menu.
2. Click the Advanced system settings link.
3. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
4. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
for more detail ..PATH and CLASSPATH
Set the JAVA_HOME Variable
Windows 7 – Right click My Computer and select Properties > Advanced
Windows 8 – Go to Control Panel > System > Advanced System Settings
Windows 10 – Search for Environment Variables then select Edit the system environment variables
Click the Environment Variables button.
Under System Variables, click New.
In the Variable Name field, enter either:
JAVA_HOME if you installed the JDK (Java Development Kit)
or
JRE_HOME if you installed the JRE (Java Runtime Environment). In the Variable Value field, enter your JDK or JRE installation path .
Open Command Prompt as Administrator.
Set the value of the Environment variable to your JDK (or JRE) installation path as follows:
2 errors:
You are missing the
bin
folder. Usually the correct path isC:\Program Files\Java\jdk_version\bin
JAVA_HOME
is usually used by some script or program, if you are interested on running java tools fromcmd
you have to add that directory toPATH
Make sure that the jdk.xxxxx/jre/bin folder is in your PATH