I'm using ant 1.7.0 and installed java 1.6 which is in JAVA_HOME.
I want to build a project using java 1.5 so I've exported JAVA_HOME to my java 1.5 directory.
java -version says 1.5
When I run ant it uses java 1.6
Any help? Thanks
I'm using ant 1.7.0 and installed java 1.6 which is in JAVA_HOME.
I want to build a project using java 1.5 so I've exported JAVA_HOME to my java 1.5 directory.
java -version says 1.5
When I run ant it uses java 1.6
Any help? Thanks
According to the ant manual, setting JAVA_HOME should work - are you sure the changed setting is visible to ant?
Alternatively, you could use the JAVACMD variable.
How and where did you export it?
Did you add it to ant.bat/.sh
e.g.: set JAVA_HOME=D:\usr\local\java\jdk1.5
?
You can also specify in a javac task what level of compatibility ( 1.4, 1.5, 1.6 ) you want to use, you can set the "source" and "target" level values, check the docs here : Javac task documentation
You can use the target and source properties on the javac tag to set a target runtime. The example below will compile any source code to target version 1.4 on any compiler taht supports version 1.4 or later.
<javac compiler="classic" taskname="javac" includeAntRuntime="no" fork=" deprecation="true" target=" source="1.4" srcdir="${src}" destdir="${classes}">
Note: The 'srcdir' and 'destdir' are property values set else where in the build script,
e.g. <property name="classes" value="c:/classes" />
You could achieve that with following steps if you are using eclipse.
Right click on the task in your ant build file (build.xml).
Mouse over "Run As", click on "External Tool Configurations..."
Add followings to "Arguments":
-Dant.build.javac.target=1.5 -Dant.build.javac.source=1.5