I get the error:
C:\\dev\\ws\\springapp\\build.xml:81: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not
I was facing the same problem, making the executable property in the javac tag to be set to the location of javac.exe resolved the problem for me. This resolved the problem
<javac srcdir="${srcDir}" destdir="${buildDir}" fork="true" executable="C:\Program Files\Java\jdk1.7.0_03\bin\javac"/>
I hope you are aware about System and User environmental variables. The user ones are preferred over system. If you have set your JAVA_HOME in system variables and if there is an entry for the same in user variables, then you will get the latter one only.
Right click on My computer, Go to properties, Select Advanced tab and click on Environmental variables to see the list of user and system environment variables.
Make sure you do not use the trailing semicolon: This will not work:
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_29;
This will:
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_29
When you say you have "clearly set" JAVA_HOME to "C:\Program Files\Java\jdk1.6.0_14" - is that what you see when you run "set" from the command line? I believe Ant will guess at a value for JAVA_HOME if one isn't set at all... is it possible that you've set JAVAHOME instead of JAVA_HOME?
If it's nothing like that, I suggest you edit the ant.bat
batch file (and whatever it calls - I can't remember whether it's convoluted or not offhand) to print out JAVA_HOME at the start and at various other interesting places.
In eclipse set the installed JRE setting to the JDK - in the project (project properties -> Java Build Path-> Libraries), or global default in preferences (Java->Installed JREs). The eclispe setting is stronger than the system variable.
When everything else is correct try the following
Note: Add tools.jar for the java compiler that you want to use and give preference to it by moving it up in the list of tools.jar when multiple tools.jar (java compilers) are present.