Java – ant buildfile setting javac location

antbuildjavaxml

I'm editing the buildfile of an old project. When I add some jar files to the project that use Java 1.6, it won't build. It says

[javac] javac: invalid target release: 1.6

So clearly I need to tell the ant buildfile to use javac 1.6.

How do I do this? I have JDK1.6 installed on my system, but the default javac is 1.5. I don't want to change the default javac… I just want to set the javac location in this one proejct to JDK1.6/bin/javac. How do I do this in the XML of an ant buildfile?

Thanks,
ktm

Best Answer

This was pulled from the javac task documentation

<javac srcdir="" 
         destdir=""
         executable="path-to-java16-home/bin/javac" 
         fork="true"
         taskname="javac1.6" />