[英]How to build a jar with different java version with ANT
I tried to build a jar file using java 1.5. 我尝试使用Java 1.5构建jar文件。 I use eclise and I specified the java version as 1.5 in below areas.
我使用eclise,并在以下区域中将Java版本指定为1.5。
But after the jar is built all the classes were built in 1.7 (major version 51) I want them in 1.5.(49) This is the result for javap -verbose MyClassInBuiltJar
但是在构建jar之后,所有类都在1.7(主要版本51)中构建,我希望在1.5中构建它们。(49)这是
javap -verbose MyClassInBuiltJar
的结果
SourceFile: "Program.java"
minor version: 0
major version: 51
Constant pool:
It's probably not ANT that cause the issue, you may need to change the project's JRE
and recompile the project with the 1.5 JRE
. 引起问题的可能不是ANT,您可能需要更改项目的
JRE
并使用1.5 JRE
重新编译项目。
You can also try to specify the JRE used directly in your build.xml
file. 您还可以尝试指定直接在
build.xml
文件中使用的JRE。
You need to explicitly specify the source and target in the build.xml: 您需要在build.xml中明确指定源和目标:
<property name="javac.source" value="1.5"/>
<property name="javac.target" value="1.5"/>
<javac source="${javac.source}" target="${javac.target}">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.