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?
To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.
Short answer, YES, you do need to set JAVA_HOME.
Verify JAVA_HOME Open a Command Prompt window (Win⊞ + R, type cmd, hit Enter). Enter the command echo %JAVA_HOME% . This should output the path to your Java installation folder. If it doesn't, your JAVA_HOME variable was not set correctly.
Find JDK Installation Directory
First you need to know the installation path for the Java Development Kit.
Open the default installation path for the JDK:
C:\Program Files\Java
There should be a subdirectory like:
C:\Program Files\Java\jdk1.8.0_172
Note: one has only to put the path to the jdk without /bin in the end (as suggested on a lot of places). e.g. C:\Java\jdk1.8.0_172 and NOT C:\Java\jdk1.8.0_172\bin !
Set the JAVA_HOME Variable
Once you have the JDK installation path:
Note: You might need to restart Windows
The complete article is here, on my blog: Setting JAVA_HOME Variable in Windows.
What worked for me was adding the %JAVA_HOME%\bin
to the Path environment variable with the JAVA_HOME
environment variable pointing to the jdk
folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With