Вы находитесь на странице: 1из 3

6/11/13

java ee - How to set java_home on Windows 7? - Stack Overflow

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.

How to set java_home on Windows 7?


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... up vote C : \ U s e r s \ D e r e k \ D e s k t o p \ e c l i p s e \ e c l i p s e \ g l a s s f i s h \ s e t u p . x m l : 1 6 1 :T h ef o l l o w i n ge r r o r o c c u r r e dw h i l ee x e c u t i n gt h i sl i n e : 21 C : \ U s e r s \ D e r e k \ D e s k t o p \ e c l i p s e \ e c l i p s e \ g l a s s f i s h \ s e t u p . x m l : 1 4 1 :T h ef o l l o w i n ge r r o ro c c u r r e dw h i l ee x e c u t i n gt h i sl i n e : : \ U s e r s \ D e r e k \ D e s k t o p \ e c l i p s e \ e c l i p s e \ g l a s s f i s h \ s e t u p . x m l : 1 3 7 :P l e a s es e tj a v a . h o m et oaJ D Ki n s t a l l a t i o n down C vote T o t a lt i m e :1s e c o n d favorite C : \ U s e r s \ D e r e k \ D e s k t o p \ e c l i p s e \ e c l i p s e \ g l a s s f i s h > l i b \ a n t \ b i n \ a n tfs e t u p . x m l 16 U n a b l et ol o c a t et o o l s . j a r .E x p e c t e dt of i n di ti nC : \ P r o g r a mF i l e s \ J a v a \ j r e 6 \ l i b \ t o o l s . j a r
B u i l d f i l e :s e t u p . x m l B U I L DF A I L E D

windows-7 java-ee java-home system-variable asked Apr 12 '10 at 2:37 share|improve this question Derek 239249 76 Derek, 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
active oldest votes 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 : \ P r o g r a mF i l e s \ J a v a

There should be a subdirectory like


C : \ P r o g r a mF i l e s \ J a v a \ j r e 6

Set the JAVA_HOME Variable Once you have the JDK installation path: up vote 86 down vote 1. 2. 3. 4. 5. Right-click the My Computer icon on your desktop and select Properties . Click the Advanced tab. Click the Environment Variables button. Under System Variables , click New. Enter the variable name as JAVA_HOME.
1/5

stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7

6/11/13

java ee - How to set java_home on Windows 7? - Stack Overflow

6. Enter the variable value as the installation path for the Java Development Kit. 7. Click OK. 8. Click Apply Changes . You might need to restart windows. The complete article is here, on my blog: Setting JAVA_HOME Variable in Windows edited Mar 25 at 6:35 answered Jun 29 '11 at 13:27 share|improve this answer Andrew Barber 22.7k73368 Lucifer 1,45721530

11 6

thanks. 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 God 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

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 up vote 42 down vote share|improve this answer fogedi 550512 +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 Lucifer's comment about how to find the JAVA_HOME system variable, and YOUR comment about how to set the path, should solve this 1 problem for everybody. David Is Not Here Aug 31 '12 at 14:14 5 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. up vote 6 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) down vote answered Apr 12 '10 at 2:55 share|improve this answer edited Apr 12 '10 at 3:40 Romain Hippeau 14.4k21535 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. answered Jun 11 '10 at 17:04

Windows 7
up vote 2 down vote 1. 2. 3. 4. 5. Select Computer from the Start menu Choose System Properties from the context menu Click Advanced system settings > Advanced tab Click on Environment Variables, under System Variables, find PATH, and click on it. 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. edited Oct 5 '12 at 9:27 answered Aug 17 '12 at 4:14 share|improve this answer
stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7 2/5

6/11/13

java ee - How to set java_home on Windows 7? - Stack Overflow

code-jaff 1,708417

HATCHA 10310

http://javahowto.blogspot.com/2006/05/javahome-vs-javahome.html Control Panel > Java, Java tab, click the View button. In Runtime Parameters, put:
D j a v a . h o m e = Y O U R _ P A T H _ H E R E

up vote 1 down vote

Or when you execute Java you can add that command line switch to the command:
j a v aD j a v a . h o m e = P A T HS o m e J a v a A p p

answered Apr 12 '10 at 2:39 share|improve this answer Ricket 7,51345092 run eclipse as Administrator. up vote 1 down vote that solved my problem. I`m still digging for the logic behind it. answered Aug 12 '10 at 12:00 share|improve this answer muscailie 112 1 I 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 In Eclipse: W i n d o w > P r e f e r e n c e s > J a v a > I n s t a l l e dJ R E s 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. up vote 1 down vote share|improve this answer edited Nov 22 '12 at 19:55 answered May 8 '11 at 1:21 0x499602D2 18.2k62357 Berg 111

You closed cmd and reopened it? Also it looks like you are pointed to the JRE not the JDK. Have you installed the JDK? up vote 0 down vote answered Apr 12 '10 at 2:39 share|improve this answer 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. Derek Apr 12 '10 at 2:43 I've even restarted.........a few times since........ Derek Apr 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 anger Apr 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 Derek Apr 12 '10 at 2:59 In what context are you running cmd.exe? anger Apr 12 '10 at 3:13 While adding your Java directory to your P A T Hvariable, 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 P A T Hwould not work. After checking, I've found j a v a . e x ein my W i n d o w s \ S y s t e m 3 2directory and it looks like the first one wins, when there are several files with the same name in your P A T H ... edited May 23 at 15:13 answered May 23 at 14:49 share|improve this answer
stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7 3/5

up vote 0 down vote

Вам также может понравиться