Java 1.7 required to launch ant build environment, but you can compile class files with any JDK. By default ant using javac and javaw from launch environment, but you can override it within ant tasks.
I used the following constants in the examples:
<property name="javac.location" value="c:/Program Files/Java/jdk1.6.0_45/bin/javac.exe" />
<property name="java.location" value="c:/Program Files/Java/jdk1.6.0_45/bin/javaw.exe" />
Java compilation:
You can define javac location parameter named "executable":
<javac srcdir="@{source.dir}" destdir="@{target.dir}" debug='@{debug}' encoding="UTF-8" fork="true" source="@{source}" target="@{target}" executable="${javac.location}">
After this, ant use javac to compile class files from JDK 1.6.
To run application from ant, with java 1.6, use jvm argument for java task:
<java classname="com.google.gwt.dev.Compiler" fork="yes" failonerror="true" maxmemory="${gwt.compile.maxmemory}" jvm="${java.location}">
Some ant task use the default compiler by default, for example the wsimport-ant task (it's generate source files from wsdl and compile it, with default java). To prevent this, run wsimport with -Xnocompile argument, and compile generated source files with javac (see above).
<wsimport-ant xadditionalHeaders="true">
<xjcarg value="-XautoNameResolution" />
<arg value="-d" />
<arg value="${src-gen.dir}/wsdls" />
<arg value="-keep" />
<arg value="@{wsdlsource}" />
<arg value="-Xnocompile" />
</wsimport-ant>
This methods work flawlessly in latest eclipse (Neon .3) with Oracle JDK 1.6 (or any other JDK).