Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAVA_HOME variable

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!

like image 903
Sapphire Avatar asked Sep 15 '11 22:09

Sapphire


People also ask

What is JAVA_HOME variable?

JAVA_HOME is an operating system (OS) environment variable which can optionally be set after either the Java Development Kit (JDK) or the Java Runtime Environment (JRE) is installed. The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed.

How do I set the JAVA_HOME variable?

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.

Can I set JAVA_HOME in user variable?

Click on the Environment Variables button. Click on the New button under System Variables. Set JAVA_HOME as the environment variable name. Set the location of the JDK installation as the environment variable Value.

Is it necessary to set JAVA_HOME PATH?

Do we need to set both JAVA_HOME and PATH? Some modern programs are intelligent enough to extract the JDK location from PATH if JAVA_HOME is not set. For example, with Gradle you can set either PATH or JAVA_HOME and it will run fine. Other programs, such as the Eclipse IDE, need at least the PATH in order to startup.


2 Answers

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

like image 105
mihk3l Avatar answered Sep 22 '22 16:09

mihk3l


Try setting it to

JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0\jre
like image 42
Jason Dean Avatar answered Sep 26 '22 16:09

Jason Dean