1

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?

3
  • What about JDK_HOME and PATH? There is no such thing as JAVA_PATH as far as I know. Commented Jul 11, 2013 at 14:45
  • You could run java with only setting Path variable.. Commented Jul 11, 2013 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 Commented Jul 11, 2013 at 14:49

7 Answers 7

4

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
Sign up to request clarification or add additional context in comments.

2 Comments

Interesting... Does it also copy javac et al if you install a JDK?
@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).
1

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"));
  }
}

3 Comments

After typing c:\echo %PATH%, I did not find "JAVA_PATH" setting in the output. But why Eclipse can still run? Thanks.
@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.
You can use the Test class, I pasted above, inside Eclipse and find out what Eclipse is using.
1

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?

Setting the JAVA_HOME Variable in Windows

Installing Java on Windows 7 and setting-up the JAVA_HOME

Comments

0

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.

2 Comments

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

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

Comments

0

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]

1 Comment

Welcome to Stack Overflow! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.