André Stannek
André Stannek

Reputation: 7863

Finding the Java compiler used by Ant

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

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:

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?

Upvotes: 2

Views: 1425

Answers (1)

Andr&#233; Stannek
Andr&#233; Stannek

Reputation: 7863

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

Upvotes: 1

Related Questions