namalfernandolk
namalfernandolk

Reputation: 9134

How to build a jar with different java version with ANT

I tried to build a jar file using java 1.5. I use eclise and I specified the java version as 1.5 in below areas.

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

SourceFile: "Program.java"
minor version: 0
major version: 51
Constant pool:

Upvotes: 1

Views: 2893

Answers (3)

kofemann
kofemann

Reputation: 4413

You need to explicitly specify the source and target in the build.xml:

<property name="javac.source"  value="1.5"/>
<property name="javac.target"  value="1.5"/>
<javac source="${javac.source}"  target="${javac.target}">

Upvotes: 0

b4gam
b4gam

Reputation: 61

You can use source=1.5 and target=1.5 in javac ant task. See here for details javac

Upvotes: 0

Semih Yagcioglu
Semih Yagcioglu

Reputation: 4101

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.

You can also try to specify the JRE used directly in your build.xml file.

Upvotes: 1

Related Questions