在ant javac中设置Java的目标版本 [英] Setting the target version of Java in ant javac
本文介绍了在ant javac中设置Java的目标版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用 ant (1.7.0) 编译一个 jar 文件才能在特定版本的 Java (1.5) 下运行.我的机器上目前有 Java 1.6.我试过设置:
I need to compile a jar file using ant (1.7.0) to run under a specific version of Java (1.5). I currently have Java 1.6 on my machine. I have tried setting:
<target name="compile">
<javac compiler="javac1.5" target="1.5" srcdir=.../>
</target>
我也删除了
<property name="build.compiler" value="modern"/>
并且没有属性文件.我在 Linux/SUSE 上运行 Java 1.6
and there is no properties file. I am running Java 1.6 on Linux/SUSE
还有一种简单的方法可以确定 jar 文件中的 Java 版本.
Also is there a simple way of determining which version of Java is expected in the jar file.
推荐答案
使用目标"属性并删除编译器"属性.请参阅此处.所以它应该是这样的:
Use "target" attribute and remove the 'compiler' attribute. See here. So it should go something like this:
<target name="compile">
<javac target="1.5" srcdir=.../>
</target>
希望能帮到你
这篇关于在ant javac中设置Java的目标版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文