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 compiler
Line where the build stops:
<javac destdir="${classes.home}" debug="on" fork="true" memoryinitialsize="512M" memorymaximumsize="1G">
<classpath refid="classpath"/>
<src path="${source.home}"/>
</javac>
Has anyone faced a similar problem before? or does anybody know what's wrong here?
System Information: Eclipse Helio, JDK 1.5
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 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
I had the same problem and removed the attribute fork from javac and problem was gone.
We hit the same issue on a windows build machine whereas locally (on a unix machine) everything worked out. Fork = true didnt helped either, it resulted in a Process fork failed exception also only on the build server
Research
After some research, we had a clue that the classpath might be too long. We recreated the exact folder structure locally on a windows machine and we hit the same issue and we saw that the classpath was way too long (we used -v and -d for details how long it was) and this was the cause of the error.
Solution
The solution was to create a jar, which contains only the manifest with all the libraries, see this answer for more details
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.
I faced the same problem, and here is my advice, maybe it will help someone.
In fact, message
Error running javac.exe compiler
means that something went wrong. The question is, what exactly. When Ant runsjavac
task withfork="true"
flag, it doesn't print any error details. In my case, it didn't print them even after I addedverbose="true"
, as suggested here. Solution was to add -verbose flag to Ant command line:After this, Ant starts printing full error messages, so you are able to fix a problem.