When I run my Ant build in Eclipse, I\'m getting the following error message and the Ant build fails.
Error Message: Error running javac.exe compile
I had the same problem and removed the attribute fork from javac and problem was gone.
Configuring eclipse to point to JDK instead of JRE did not work for me.
With further investigation, I solved this problem by stopping the build process from forking.
In your build.xml, remove the attribute fork
from <javac>
tag.
The accepted answer didn't work for me. But right-clicking in Ant and setting the Java Runtime Environment (JRE) to the Jave Development Kit (JDK) worked for me.
Abhi Rampal's answer is the step by step the same way I solved the problem on my eclipse.
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.
I solved this by checking my Environment Variables in my Windows 7. I found that JAVA_HOME is pointing to C:\ Program Files (x86)\Java\jdk1.6.0_31 when it supposed be C:\ Program Files\Java\jdk1.6.0_31. If you want to know how read this
I fixed the problem like this:
My Java home folder had the wrong path. It should have been C:\Program Files (x86)\Java\jdk1.5.0_15
but instead it was C:\Program Files (x86)\Java\jdk1.5.0_15\bin
.
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.