Please set java.home to a JDK installation

Problem:
c:\glassfish>lib\ant\bin\ant -f setup.xml Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar

Buildfile: setup.xml

all:

get.java.home:

setup.init:

check-java:

get.java.home:

setup.init:

validate-java:

[echo] Current Java Version 1.6.0_10

BUILD FAILED
C:\glassfish\setup.xml:156: The following error occurred while executing this line:
C:\glassfish\setup.xml:136: The following error occurred while executing this line:
C:\glassfish\setup.xml:132: Please set java.home to a JDK installation

The problem is: Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar

Solutions:

Step 1: set JAVA_HOME environment variable to your JDK install directory

Step 2: restart cmd window, stupid windows doesn't recognize it before cmd window is restarted.

Category >> Real Methods  
If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
<pre><code> 
String foo = "bar";
</code></pre>
  • ordinary guy

    Thanks for step 2 about restarting cmd, spend a lot of time to figure out what is happening in this awesome Windows system. Huge thanks!

  • samyraj

    hi,

    because of cmd prompt i searched lot. aftre that i have restarted build successfull.thanks..

  • Larissa

    Thank you. Problem is now resolved.

  • Manikandan

    Thanks..I also have same problem now it resolved..

  • Santosh Shetty

    Thanks alot for the solution I was knowing Step1 but step2 stupid windows ….worked for me 🙂