Getting Error running javac.exe compiler message, while using Ant in Eclipse
I had the same problem and the issue was, in eclipse java.home was referring to JRE instead of JDK. I changed it and the build was successful. You can do the following to change it to JDK:
Preferences > Java > Installed JRE's > Add... For 'JRE Type' select 'Standard VM' > Next > Directory: select your JDK directory (instead of JRE) (in my case: C:\Program Files\Java\jdk1.6.0_16 ), press OK.
Now, you are back at 'Installed JRE's', select the JDK here also.
The below post helped in finding the solution. JAVA_HOME points to the wrong place
If the accepted answer above doesn't solve the problem for you (as it didn't for me), after updating the java.home to JDK instead of JRE as suggested in the accepted answer above, Go to Run -> External Tools -> External Tools Configuration -> select your build.xml on the left menu -> select JRE tab -> select the JDK(from the dropdown) for Separate JRE radio button option -> Click Run.
This should fix the problem.
I had the same problem and removed the attribute fork from javac and problem was gone.
Maybe the javac problem is because "javac.exe" is not in your System PATH, please edit your system path and add your JDK's /bin directory to it to correct this problem.
Open a shell or command prompt and try typing: javac to check if the system path is set correctly.