Setting the target version of Java in ant javac

antjavac

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>

I have also removed

<property name="build.compiler" value="modern"/>

and there is no properties file. I am running Java 1.6 on Linux/SUSE

Also is there a simple way of determining which version of Java is expected in the jar file.

Best Answer

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>

Hope this helps

Related Topic