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.
Which version of Java is required to run Apache Ant? You will need Java installed on your system, version 1.8 or later required. The later the version of Java, the more Ant tasks you get. The git branch 1.9.
You use the -source option to specify the java version used for compilation and you use the -target option to specify the lowest java version to support. eg. If I specify a target of 1.4, then my program will not be able to run on java 1.3 or lower. see the following javac documentation for more info.
Check your installation by opening a command line and typing ant -version into the commend line. The system should find the command ant and show the version number of your installed Ant version.
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
Both source and target should be specified. I recommend providing ant defaults, that way you do not need to specify source/target attribute for every javac task:
<property name="ant.build.javac.source" value="1.5"/> <property name="ant.build.javac.target" value="1.5"/>
See Java cross-compiling notes for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With