Upload
veeru-mudiraj
View
215
Download
0
Embed Size (px)
Citation preview
7/28/2019 Set Java_home on Windows 7
1/3
6/11/13 java ee - How to set java_home on Windows 7? - Stack Overflow
stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7
Stack Exchange
sign up | log in | careers 2.0 |
search
Stack Overflow
Questions
Tags
Tour
Users
Ask Question
Tell me more
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Howto set java_home on Windows 7?
up vote
21
down
vote
favorite
16
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 name
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 lin
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
windows-7java-eejava-homesystem-variable
share|improve this question
asked Apr 12 '10 at 2:37
Derek
239249
76Derek, can you be a good citizen and accept some answers ? If not people will not bother answering your questions. Romain Hippeau May 4 '10 at
3:25
9 Answers
activeoldestvotes
up vote 86
down vote
Find JDK Installation Directory
First you need to know the installation path for the Java Development Kit.
Open the default installation path for the Java Development Kit
C:\Program Files\Java
There should be a subdirectory like
C:\Program Files\Java\jre6
Set the JAVA_HOME Variable
Once you have the JDK installation path:
1. Right-click the My Computer icon on
2. your desktop and select Properties.
3. Click the Advanced tab. Click the
4. Environment Variables button. UnderSystem Variables, click New.
5. Enter the variable name as JAVA_HOME.
http://stackoverflow.com/q/2619584http://stackoverflow.com/posts/2619584/edithttp://stackoverflow.com/users/312402/derekhttp://stackoverflow.com/abouthttp://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7http://stackoverflow.com/questions/askhttp://stackoverflow.com/usershttp://stackoverflow.com/abouthttp://stackoverflow.com/http://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7?answertab=votes#tab-tophttp://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7?answertab=oldest#tab-tophttp://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7?answertab=active#tab-tophttp://stackoverflow.com/users/313137/romain-hippeauhttp://stackoverflow.com/users/312402/derekhttp://stackoverflow.com/users/312402/derekhttp://stackoverflow.com/posts/2619584/edithttp://stackoverflow.com/q/2619584http://stackoverflow.com/questions/tagged/system-variablehttp://stackoverflow.com/questions/tagged/java-homehttp://stackoverflow.com/questions/tagged/java-eehttp://stackoverflow.com/questions/tagged/windows-7http://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7#http://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7http://stackoverflow.com/abouthttp://stackoverflow.com/questions/askhttp://stackoverflow.com/usershttp://stackoverflow.com/abouthttp://stackoverflow.com/tagshttp://stackoverflow.com/questionshttp://stackoverflow.com/http://careers.stackoverflow.com/http://stackoverflow.com/users/login?returnurl=%2fquestions%2f2619584%2fhow-to-set-java-home-on-windows-7http://stackoverflow.com/users/login?returnurl=%2fquestions%2f2619584%2fhow-to-set-java-home-on-windows-7http://stackexchange.com/7/28/2019 Set Java_home on Windows 7
2/3
6/11/13 java ee - How to set java_home on Windows 7? - Stack Overflow
stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7
6. Enter the variable value as the installation path for the Java Development Kit.
7. ClickOK.
8. ClickApply Changes.
You might need to restart windows.
The complete article is here, on my blog: Setting JAVA_HOME Variable in Windows
share|improve this answer
edited Mar 25 at 6:35
Andrew Barber
22.7k73368
answered Jun 29 '11 at 13:27
Lucifer
1,45721530
11thanks. finally I realized that one has only to put the path to the jdk without /bin in the end (as suggested on alot of places). e.g.
C:\Java\jdk1.6.0_31 and NOT C:\Java\jdk1.6.0_31\bin ! salocinx Mar 20 '12 at 22:24
6God forbid there was an installer that did this step for you :) I just switched from the Enterprise version to the Community version and I was
convinced I downloaded the wrong thing because it was one-click on the Enterprise version :p w00te Apr 26 '12 at 18:25
Sometimes, the system varible changes does not take effect until you restart the windows. Andy May 30 at 9:42
up vote 42
down vote
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
share|improve this answer
answered Jun 11 '10 at 17:04
fogedi
550512
5+1 adding %JAVA_HOME%\bin to bath fixed my issue, and here I thought 'JAVA_HOME' would be enough on windows 7 Jakub Nov 29
'10 at 16:38
Awesome, Thanks a ton. And yes, this is the correct answer - @Lucifer. Anand S Feb 19 '12 at 16:59
1Lucifer's comment about how to find the JAVA_HOME system variable, and YOUR comment about how to set the path, should solve this
problem for everybody. David Is Not Here Aug 31 '12 at 14:14
up vote 6
down
vote
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)
share|improve this answeredited Apr 12 '10 at 3:40
answered Apr 12 '10 at 2:55
Romain Hippeau
14.4k21535
up vote 2
down vote
This is official solution for set java environment from www.java.com Here
There are solution for Win7, Vista, XP, Linux/Solaris and other shell.
Example.
Windows 7
1. Select Computer from the Start menu
2. Choose System Properties from the context menu
3. Click Advanced system settings > Advanced tab
4. Click on Environment Variables, under System Variables, find PATH, and click on it.
5. In the Edit windows, modify PATH by adding the location of the class to the value for PATH.If you do not have the item PATH, you
may select to add a new variable and add PATH as the name and the location of the class as the value.
6. Reopen Command prompt window, and run your java code.
share|improve this answer
edited Oct 5 '12 at 9:27 answered Aug 17 '12 at 4:14
http://stackoverflow.com/users/1510985/hatchahttp://stackoverflow.com/users/1592398/code-jaffhttp://stackoverflow.com/posts/11999682/revisionshttp://stackoverflow.com/posts/11999682/edithttp://stackoverflow.com/a/11999682http://www.java.com/en/download/help/path.xmlhttp://www.java.com/en/download/help/path.xmlhttp://stackoverflow.com/users/313137/romain-hippeauhttp://stackoverflow.com/users/313137/romain-hippeauhttp://stackoverflow.com/posts/2619638/revisionshttp://stackoverflow.com/posts/2619638/edithttp://stackoverflow.com/a/2619638http://stackoverflow.com/users/1499731/david-is-not-herehttp://stackoverflow.com/users/614285/anand-shttp://stackoverflow.com/users/158014/jakubhttp://stackoverflow.com/users/342598/fogedihttp://stackoverflow.com/users/342598/fogedihttp://stackoverflow.com/posts/3024721/edithttp://stackoverflow.com/a/3024721http://stackoverflow.com/users/437961/andyhttp://stackoverflow.com/users/857994/w00tehttp://stackoverflow.com/users/1198474/salocinxhttp://stackoverflow.com/users/78077/luciferhttp://stackoverflow.com/users/78077/luciferhttp://stackoverflow.com/users/237838/andrew-barberhttp://stackoverflow.com/users/237838/andrew-barberhttp://stackoverflow.com/posts/6521412/revisionshttp://stackoverflow.com/posts/6521412/edithttp://stackoverflow.com/a/6521412http://www.robertsindall.co.uk/blog/setting-java-home-variable-in-windows/7/28/2019 Set Java_home on Windows 7
3/3
6/11/13 java ee - How to set java_home on Windows 7? - Stack Overflow
stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7
code-jaff
1,708417
HATCHA
10310
up vote 1 down vote
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
share|improve this answer
answered Apr 12 '10 at 2:39
Ricket
7,51345092
up vote 1
down
vote
run eclipse as Administrator.
that solved my problem. I`m still digging for the logic behind it.
share|improve this answer
answered Aug 12 '10 at 12:00
muscailie
112
1I can't say I understand this exactly, but maybe eclipse is actually just giving the wrong error message here. When you run it as a non-admin, it can't
delete the .jar files or something and then falsely reports that it didn't find javac. Anyway, this solution worked for me too. Jess Jun 15 '11 at 23:02
up vote 1 down
vote
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.
share|improve this answer
edited Nov 22 '12 at 19:55
0x499602D2
18.2k62357
answered May 8 '11 at 1:21
Berg111
up vote 0
down vote
You closed cmd and reopened it? Also it looks like you are pointed to the JRE not the JDK. Have you installed the JDK?
share|improve this answer
answered Apr 12 '10 at 2:39
anger
555210
I have definitely installed the JDK and it's located in C:\Sun\SDK\jdk\bin which I have set java_home to. DerekApr 12 '10 at 2:43
I've even restarted.........a few times since........ DerekApr 12 '10 at 2:44
Still it seems to be looking in C:\Program Files\Java\jre6\lib\ c Can you do echo %JAVA_HOME% in your command prompt and see what it
reports angerApr 12 '10 at 2:46
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 DerekApr 12 '10 at 2:59
In what context are you running cmd.exe? angerApr 12 '10 at 3:13
up vote
0 down
vote
While adding your Java directory to yourPATH variable, you might want to put it right at the beginning of it. I've had the problem, that putting the Java
directory at the end of the PATH would not work. After checking, I've found java.exe in my Windows\System32 directory and it looks like the first one
wins, when there are several files with the same name in your PATH...
share|improve this answer
edited May 23 at 15:13 answered May 23 at 14:49
http://stackoverflow.com/users/2414128/user2414128http://stackoverflow.com/users/850848/martin-prikrylhttp://stackoverflow.com/posts/16717130/revisionshttp://stackoverflow.com/posts/16717130/edithttp://stackoverflow.com/a/16717130http://stackoverflow.com/users/202291/angerhttp://stackoverflow.com/users/312402/derekhttp://stackoverflow.com/users/202291/angerhttp://stackoverflow.com/users/312402/derekhttp://stackoverflow.com/users/312402/derekhttp://stackoverflow.com/users/202291/angerhttp://stackoverflow.com/users/202291/angerhttp://stackoverflow.com/posts/2619587/edithttp://stackoverflow.com/a/2619587http://stackoverflow.com/users/743547/berghttp://stackoverflow.com/users/743547/berghttp://stackoverflow.com/users/701092/0x499602d2http://stackoverflow.com/users/701092/0x499602d2http://stackoverflow.com/posts/5925055/revisionshttp://stackoverflow.com/posts/5925055/edithttp://stackoverflow.com/a/5925055http://stackoverflow.com/users/194725/jesshttp://stackoverflow.com/users/418367/muscailiehttp://stackoverflow.com/users/418367/muscailiehttp://stackoverflow.com/posts/3467370/edithttp://stackoverflow.com/a/3467370http://stackoverflow.com/users/47493/rickethttp://stackoverflow.com/users/47493/rickethttp://stackoverflow.com/posts/2619590/edithttp://stackoverflow.com/a/2619590http://javahowto.blogspot.com/2006/05/javahome-vs-javahome.htmlhttp://stackoverflow.com/users/1510985/hatchahttp://stackoverflow.com/users/1592398/code-jaff