Search code examples
javaeclipseantjavacapt

APT ANT task fails in eclipse but works from shell


I have a ant javac task which is supposed to run some annotation processor. It works fine when run from a batch file, but fails with

Error running javac.exe compiler

when started from eclipse. Normal compiling javac tasks work just fine.

I guess ant started from eclipse uses some different compiler?
How do I change it to the normal compiler? Or make it work in any way?


Solution

  • It is usually because of a missing tool.jar

    You are missing a tools.jar on the runtime classpath of Ant used in the Eclipse integration.
    If you start Eclipse with a JDK install (using the -vm argument), tools.jar will be added automatically.
    Otherwise, you can add it yourself using Window>Preferences>Ant>Runtime>Classpath. (see also this thread)

    http://web.archive.org/web/20130109065622/http://img246.i_mageshack.us/img246/9712/eclipseantruntime.png

    Note: a fork="true" can also be problematic.