JAVA_HOME variable
Asked Answered
E

3

9

I set my JAVA_HOME variable to point to the jdk and I added %JAVA_HOME%\bin to the Path variable. However, my ant script is not able to find the jdk. It's looking into the wrong folder for Java compiler. here's the error I'm getting.

com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to C:\Program Files\Java\jre6

I set my JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0

What am I doing wrong? Please help!

Encyclopedia answered 15/9, 2011 at 22:26 Comment(5)
What other folders do you see in 'C:\Program Files (x86)\Java\jdk1.7.0' just make sure there is not another jdk1.7.0 folder inside this which gets created by unzip to optionDjakarta
no there's no other jdk1.7.0 inside it.Encyclopedia
Is there a JRE folder? Also, are you intending to use the 32-bit JDK? The fact that it is in the Program Files (x86) folder indicates that it is the 32-bit version.Protectionism
@Encyclopedia You can create command file for running you ant script. Before launching ant you can set PATH variable to guarantee correct java calling.Putamen
the message "It is currently set to C:\Program Files\Java\jre6" indicates you did not change JAVA_HOME properly. Open a commandline and verify it by running set javaPelaga
S
27

If your Java installation directory has a space in its path name, you should use the shortened path name (e.g. C:\Progra~1\Java\jre6) in the environment variable instead.

  • Progra~1 = 'Program Files'
  • Progra~2 = 'Program Files(x86)'

Setting the JAVA_HOME Variable in Windows

Sartor answered 14/8, 2012 at 13:18 Comment(3)
@Nilabja, have you looked into this tutorial? Did you restart your system after altering the java_home variable?Sartor
yupp, worked on my other machines perfectly though, I may be missing some step @SartorWahkuna
Believe me if you are reading this, it worked like a charm, -From Frustrated Coder.Kersten
P
4

Try setting it to

JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0\jre
Protectionism answered 15/9, 2011 at 22:29 Comment(2)
Where are you making this change? Are you doing it in the environment variables section of Advanced Setting in your computer properties? And are you restarting the program that you are trying to access it with? This includes CMD. In my experience programs will only look for a new environment variable when they launch. What happens when you type "ECHO %JAVA_HOME%" at the command line?Protectionism
Ant is expecting a JDK, not a JRE, so this is not going to work.Ataxia
R
0

When you want to use JAVA_HOME in your path variable it is recommended to use "%JAVA_HOME%\bin" instead of %JAVA_HOME%\bin .

Roughspoken answered 17/7, 2018 at 7:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.