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!
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.
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.
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.
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.
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.
Setting the JAVA_HOME Variable in Windows
Try setting it to
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0\jre
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With