Ant configuring javac build file

I am editing the build file of an old project. When I add some jar files to a project using Java 1.6, it will not be created. It says:

[javac] javac: invalid target release: 1.6 

Therefore, I have to say that the ant build file is for using javac 1.6.

How can I do it? I have JDK1.6 installed on my system, but by default javac is 1.5. I do not want to change javac by default ... I just want to set the javac location in this JDK1.6 / bin / javac prospectus. How to do this in XML ant build file?

Thanks,
KTM

+7
source share
2 answers

You can create a wrapper script in which you change your JAVA_HOME before executing ant .

eg. build.sh

 export JAVA_HOME=/path/to/jdk1.6 ant " $@ " 

Now when you call build.sh , it will use java6 for javac , java and any other commands.

IMO is better than messing with build.xml (and deploying a new javac process).

+3
source

This has been extracted from javac documentation

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

All Articles