1

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.

  • Project -> Properties -> Java Compiler
  • Project -> Java Build Path -> JRE System Library
  • Ant Build File -> Run As -> ExternalToolConfiguration -> JRE

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:
ironwood
  • 8,936
  • 15
  • 65
  • 114
  • Have you checked this [link]http://stackoverflow.com/questions/1487978/setting-the-target-version-of-java-in-ant-javac[/link]? – howiewylie May 09 '13 at 10:09

3 Answers3

1

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.

Semih Yagcioglu
  • 4,011
  • 1
  • 26
  • 43
0

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

b4gam
  • 61
  • 2
0

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}">
kofemann
  • 4,217
  • 1
  • 34
  • 39