I went to the Environment Variables in 'System' in the control panel and made two new variables, one for user variables and one for system variables. Both were 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
How can I fix this problem?
One Image can fix this issue.
For More
In Eclipse:
Window->Preferences->Java->Installed JREs
Use the search feature to make sure your latest Java installation is listed; then make sure it is the one that is checked. This should be a JDK not a JRE.
This is the official solution for setting the Java environment from www.java.com - here.
There are solutions for Windows 7, Windows Vista, Windows XP, Linux/Solaris and other shells.
Example
You have to first Install JDK in your system.
Set Java Home
JAVA_HOME = C:\Program Files\Java\jdk1.7.0 [Location of your JDK Installation Directory]
Once you have the JDK installation path:
Set JAVA Path under system variable
PATH= C:\Program Files\Java\jdk1.7.0; [Append Value with semi-colon]
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 inC:\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)Run Eclipse as Administrator.
That solved my problem. I'm still digging for the logic behind it.