Showing posts with label java 1.8 not supported. Show all posts
Showing posts with label java 1.8 not supported. Show all posts

Thursday, January 4, 2018

Ant Build Problem in Eclipse Oxygen - JRE less than 1.8 is not supported

When executing ant build within Eclipse using JRE 1.6, the following error occurs:



One would ask, "Why use old JRE when there are newer and better versions?"

The answer to this question is, in some environments, there are existing legacy system that cannot be upgraded due to various reasons including financial constraints.
The Eclipse Oxygen comes with Ant version 1.10.1 plugin. Apache Ant 1.10.x requires Java Runtime 1.8, whereas Ant 1.9.x stays compatible with Java 1.5 to 1.7.

Since Ant 1.10.x requires JRE8 and above, if you run an ant build file using the default Ant Home that points to the ant plugin, the ant launcher checks for the JRE version and prevent ant from launching with older JRE. However, if you configure to run your ant build with an external Ant runtime (configure Ant Home in the classpath to point to the external Ant 1.9.x runtime), it does not block ant runtime from launching.

Below is the source code of the ant launching method in org\eclipse\ant\internal\launching\launchConfigurations\AntLauchDelegate.java 


First download Apache Ant 1.9.9 and extract it. Then, configure external ant runtime in the ant build launcher and change the Ant Home in the Classpath tab.








That's it. Now the ant build file can be executed in Eclipse with JRE6.