如何将 Ant 编译器更改为 JDK 1.6 [英] How to change Ant compiler to JDK 1.6

查看:66
本文介绍了如何将 Ant 编译器更改为 JDK 1.6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编译我的源代码以与 jre 1.6 兼容.但是,当我尝试将 javac 任务的编译器属性设置为 javac1.6 时,ant 仍会使用 javac1.7 编译我的代码.我还尝试将编译器版本设置为现代",但没有帮助.

I need to compile my source code to be compatible with jre 1.6. However, when I attempt to set the compiler attribute of the javac task to be javac1.6, ant will still compile my code with javac1.7. I have also tried setting the compiler version to be "modern" and that did not help.

<target name="compile-tests">
    <javac compiler="javac1.6" includeantruntime="false" srcdir="${test.dir}"
     destdir="${build.dir}" >
        <classpath refid="class.path" />
    </javac>
</target>

我的 JAVA_HOME 设置为 JDK 1.6:

My JAVA_HOME is set to JDK 1.6:

echo $JAVA_HOME </code> gives: <code>
/usr/lib/jvm/java-6-openjdk-amd64/

我的蚂蚁版本是:Apache Ant(TM) 版本 1.8.2

My ant version is: Apache Ant(TM) version 1.8.2

根据这篇文章,蚂蚁使用它自己的编译器.如何覆盖蚂蚁默认值?另外,根据这篇文章和ant文档,我可以设置全局 build.compiler 属性.我应该将该属性设置为什么,我该怎么做?

According to this post, ant uses its own compiler. How do I override the ant default? Also, according to this post and the ant documentation, I can set the global build.compiler property. What do I set that property to be and how might I do that?

推荐答案

我认为 Ant compiler 属性只是为了知道编译器支持哪些属性.在javac 中,通常传递给编译器的属性或选项是target.

I think Ant compiler attribute is just to know which properties are supported by the compiler. In javac in general the attribute or option to pass to the compiler is target.

您甚至不需要安装 Java 6 编译器.

You should not even need to have a Java 6 compiler installed.

这篇关于如何将 Ant 编译器更改为 JDK 1.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆