wood burning stoves*
The moose likes Beginning Java and the fly likes JDK home directory problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JDK home directory problem" Watch "JDK home directory problem" New topic

JDK home directory problem

Nagendra Shastry

Joined: Oct 26, 2010
Posts: 19

Hi All,

I have my java folder in C:\Program Files (x86). When I try to build project in eclipse using ant it is telling

D:\EVENTS_DB\b2b2-ear\build.xml:97: Unable to find a javac compiler;
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 (x86)\Java\jre6"

My JAVA_HOME variable is set as C:\Program Files (x86)\Java;

What is the probelm?
Luke Leber
Ranch Hand

Joined: Sep 20, 2013
Posts: 42

JAVA_HOME should point to the top level directory of your JDK installation (which is not the same as your JRE installation). In my case, it is "C:\Program Files\Java\jdk1.7.0_40".

Since you're using ant, I should let you know another little trick that I've picked up with it. The ant build process will exit without letting you see the terminal output. To add in a pause at the end of execution, so you can actually see the output, you can modify ANT_HOME/bin/ant.bat all the way at the bottom of the file as follows...

Just insert the pause in the omega block label before exit and you're set.

Hope it helps!

<a href="http://www.linkedin.com/in/lukeleber" rel="nofollow">

<img src="https://static.licdn.com/scds/common/u/img/webpromo/btn_viewmy_160x33.png" border="0" >

Jay Tai
Ranch Hand

Joined: Apr 25, 2012
Posts: 174

The corect JAVA_HOME setting should point to your Java directory only. You can then manipulate sub directories (like bin, libs, etc) accordingly. Try removing the jre directory from your setting so that :

JAVA_HOME=C:\Program Files (x86)\Java
Doug Slavens

Joined: Sep 10, 2013
Posts: 11
At my workplace, we build and test against a number of different JRE/JDK versions and in our build scripts we always use the top level JDK directory in the JAVA_HOME variable as Luke mentioned above. Also, JREs don't come with a javac compiler so a JDK will be necessary to call the compiler.
It is sorta covered in the JavaRanch Style Guide.
subject: JDK home directory problem