Search code examples
javaantjavac

Finding the Java compiler used by Ant


We are using a product that comes with it's own SDK. This SDK contains:

  • It's own JRE installation
  • It's own Ant installation
  • A few Ant scripts for building stuff
  • A few batch scripts that call Ant with the included scripts

Now some of the Ant scripts compile Java code, using the javac task. Now I'd like to find the javac executable that is used for that. I have checked the following:

  • The batch scripts are temporarily setting JAVA_HOME to the included JRE. The whole thing works without having another JDK installed.
  • The included JRE is a JRE and not a JDK. So there is no javac.exe to be found.
  • There is no javac.exe included anywhere else in the SDK.
  • build.compiler doesn't seem to be set anywhere in the Ant scripts.
  • The fork, executable and compiler attributes are not set on any of the javac tasks.

I'm out of ideas on where to look. What other possibility is there? How can I find the Java compiler executable that is used?

I'm omitting any Ant snippets or the like for now, since they are very complex and I'm not a 100% sure which parts are relevant. If you like to see a certain part, please tell me in the comments.

EDIT

New insights so far thanks to Robert:

There are a few taskdef. Most of them refer to a class in a jar, implementing Task. None of them import any compiler-related packages. However there is also ant-contrib loaded as a library:

<taskdef resource="net/sf/antcontrib/antlib.xml">
    <classpath>
        <pathelement location="${ant.home}/lib/ant-contrib.jar"/>
    </classpath>
</taskdef>

I'm not familiar with this library but it seems to contain some tasks, that could do the compiling. CompileWithWalls imports org.apache.tools.ant.taskdefs.Javac. But the compilewithwalls target is not called in the Ant scripts. The question remains: If a compiler is used from any of those libraries, how would it be bound to the default javac task?


Solution

  • A colleague of mine finally solved the mystery.

    What I did know was, that Ant uses the JDK located under JAVA_HOME. I was however, under the wrong assumption, that Ant uses javac.exe to compile. Well, it does not. Ant uses sun.tools.javac.Main which is located in the tools.jar. That Jar, as well as javac.exe only comes with a JDK, but in my case it was included in the products SDK and manually added to the classpath of Ant.

    Further reading: http://mindprod.com/jgloss/javacmain.html