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?
Windows 7
Go to Control Panel\All Control Panel Items\User Accounts using Explorer (not Internet Explorer!)
or
click on the Start button
click on your picture
Change my environment variables
New...
(if you don't have enough permissions to add it in the System variables section, add it to the User variables section)
Add JAVA_HOME as Variable name and the JDK location as Variable value > OK
Test:
set JAVA_HOME
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_60
goto Mycomputer(This PC) -> rightclick ->select properties -> Advanced system settings -> environment variables-> in system variables click "New" button and write JAVA_HOME in variable name and path C:\Program Files\Java\jdk1.8.0_131 were jdk is present in variable value-> click ok.
close and reopen the command prompt after setting JAVA_HOME. Sometimes changes does not reflect in the cmd opened before setting the JAVA_HOME.
you can also set JAVA_HOME through terminal itself: SET JAVA_HOME="C:\Program Files (x86)\Java\jdk1.8.0_131"
What worked for me was adding the
%JAVA_HOME%\bin
to the Path environment variable with theJAVA_HOME
environment variable pointing to thejdk
folder.In cmd (temporarily for that cmd window):
http://javahowto.blogspot.com/2006/05/javahome-vs-javahome.html
Control Panel > Java, Java tab, click the View button. In Runtime Parameters, put:
Or when you execute Java you can add that command line switch to the command: