开发者

ant buildfile setting javac location

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开发者_如何学Go, 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


This was pulled from the javac task documentation

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


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

e.g. build.sh

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

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

IMO this is better than fiddling with the build.xml (and forking a new javac process).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜