views:

3910

answers:

5

I went to the Environment Variables in 'System' in the control panel and made 2 new variables. one for user variables and one for system variables, both named JAVA_HOME and both pointing to

C:\Sun\SDK\jdk\bin

but for some reason, I still get the below error when running a java command...

BUILD FAILED
C:\Users\Derek\Desktop\eclipse\eclipse\glassfish\setup.xml:161: The following error  occurred while executing this line:
C:\Users\Derek\Desktop\eclipse\eclipse\glassfish\setup.xml:141: The following error occurred while executing this line:
C:\Users\Derek\Desktop\eclipse\eclipse\glassfish\setup.xml:137: Please set java.home to a JDK installation

Total time: 1 second
C:\Users\Derek\Desktop\eclipse\eclipse\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
A: 

You closed cmd and reopened it? Also it looks like you are pointed to the JRE not the JDK. Have you installed the JDK?

anger
I have definitely installed the JDK and it's located in C:\Sun\SDK\jdk\binwhich I have set java_home to.
Derek
I've even restarted.........a few times since........
Derek
Still it seems to be looking in C:\Program Files\Java\jre6\lib\ cCan you do echo %JAVA_HOME% in your command prompt and see what it reports
anger
in my command prompt, when I ran echo %JAVA_HOME%, it returned: C:\Users\Derek\Desktop\eclipse\eclipse\glassfish>echo %JAVA_HOME% C:\Sun\SDK\jdk\bin
Derek
In what context are you running cmd.exe?
anger
A: 

http://javahowto.blogspot.com/2006/05/javahome-vs-javahome.html

Control Panel > Java, Java tab, click the View button. In Runtime Parameters, put:

-Djava.home=YOUR_PATH_HERE

Or when you execute Java you can add that command line switch to the command:

java -Djava.home=PATH SomeJavaApp
Ricket
+2  A: 

You need to set it to C:\Sun\SDK\jdk (Assuming that is where the JDK is installed - It is not the default) - Do not put the \bin in C:\Sun\SDK\jdk\bin. If your app only runs when you are logged in as the current user then put it in the user variables - If it needs to run for all users on your system then put it in System variables.

You might also need to add %JAVA_HOME%\bin to the path also (Also it depends on whether you run it from just the user or from all users, including System)

Romain Hippeau
+2  A: 

What worked for me was adding the %JAVA_HOME%\bin to Path environment variable with the JAVA_HOME environment variable pointing to the jdk folder

fogedi
A: 

run eclipse as Administrator.

that solved my problem. I`m still digging for the logic behind it.

muscailie