I have been using Eclipse to develop java program on a windows 7 machine. It works. I also typed "java" from the command prompt, it also shows the help message. In other words, I think Java was correctly installed on this machine. However, when I open the "environmental variable" setting on this machine, I cannot find either "JAVA_HOME" setting and "JAVA PATH" setting. What is the problem of this?
-
What about `JDK_HOME` and `PATH`? There is no such thing as `JAVA_PATH` as far as I know. – fge Jul 11 '13 at 14:45
-
You could run java with only setting Path variable.. – ritesh Jul 11 '13 at 14:46
-
If you are able to run java -version and get the result about your java version in command prompt, those variable are configured – Ruchira Gayan Ranaweera Jul 11 '13 at 14:49
7 Answers
Java also copies java.exe and javaw.exe under C:\Windows\System32, there's where your java is running from.
You can confirm that by using where
commmand:
On my win7 machine:
>where java.exe
C:\Windows\System32\java.exe

- 10,935
- 8
- 31
- 39
-
-
@fge no. On my win7 box it does not locate `C:\Users\xxx>where javac.exe INFO: Could not find files for the given pattern(s).` – Bimalesh Jha Jul 11 '13 at 15:07
Some environment variables are defined at machine level and some are defined (and overwritten) at user account level. Just do following in windows cmd prompt
:
c:\echo %PATH%
or just type c:\path
and verify the output.
You can also verify java home path by writing a simple Test class like following:
public class Test {
public static void main(String[]s){
System.out.println(System.getProperty("java.home"));
}
}

- 1,464
- 9
- 17
-
After typing c:\echo %PATH%, I did not find "JAVA_PATH" setting in the output. But why Eclipse can still run? Thanks. – user297850 Jul 11 '13 at 15:00
-
@user297850 just type `c:\set` and you can see all the env values defined in your `cmd` shell. Eclipse just uses the installed JRE (from system path) and it has its own compiler. If it does not find a java on `PATH` it will throw error and terminate. – Bimalesh Jha Jul 11 '13 at 15:03
-
You can use the Test class, I pasted above, inside Eclipse and find out what Eclipse is using. – Bimalesh Jha Jul 11 '13 at 15:05
There are multitudes of links to be fond on Google regarding how to solve this in Windows. These environment variables typically do not get setup by default when installing java.
Here are some 10 second finds with with answers:
How to set java_home on Windows 7?

- 1
- 1

- 3,176
- 1
- 21
- 29
Check you PATH variable in Environment Variables. It must be set to jreInstallation/bin. Windows does not pick up java command from JAVA PATH, it picks java command from PATH variable.
Also note that once you install JDK, path is not set by installation to jdkInstallation/bin, you need to set it up explicitly.So unless you set the path to jdkInstallation/bin, javac wont be recognized.

- 1,957
- 12
- 15
-
In other words, the java was not setup on my machine even I install JDK. However, why Eclipse can still debug and run Java program – user297850 Jul 11 '13 at 14:58
-
Because eclipse does not depend on the jdk installation these days. Eclipse has its own compiler so you don't need JDK if you are working with Eclipse. – ajay.patel Jul 11 '13 at 15:00
Check your path variable in windows environmental variables. At least Java path should be there .
It may looks like this.
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Java\jdk1.7.0\bin

- 34,993
- 17
- 75
- 115
You should set path and classpath variables. Here's the link you can follow for step by step instructions.
[http://abodeqa.wordpress.com/2012/08/11/how-to-set-path/][1]

- 269
- 3
- 2
-
4Welcome to Stack Overflow! Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – jlordo Jul 11 '13 at 14:53
With Java, Groovy, Git, Heroku, Maven, and many other projects, what I always do is this:
1. Unzip the software package into a directory, for example:
C:\AeroFS\Java\jdk1.7.0_25
C:\AeroFS\Groovy\groovy-2.0.5
2. Create a HOME variable, such as JAVA_HOME or GROOVY_HOME that points to the
above locations.
3. Put these in your default system path by editing your PATH variable and
adding %JAVA_HOME%\bin and %GROOVY_HOME%\bin to the end of your PATH. In
the case of JAVA_HOME only, you might want to put it at the beginning of
the PATH to override the java.exe that rests in the WINDOWS directory
location.

- 28,471
- 61
- 196
- 289