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.
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.
Hi, I have a same problem and Your method helped for me.
ReplyDeleteBut after same upgrade of Oxygen this fix not work.
I found another solution https://stackoverflow.com/questions/45785949/eclipse-oxygen-upgrade-java-virtual-machine-launcher-a-java-exception-has-o
In my eclipse envronment I must add only one jar to list:
eclipse\configuration\org.eclipse.osgi\1088\0\.cp\ant_tasks\resources-ant.jar
After that Ant 1.9 with java 1.7 works again.
My God!!!
DeleteThanks to you, i can fix my problem!
Really Thank you~!!!
Hi, it's really helpful!!!
ReplyDeleteThanks a lot!
Before this, I've tried lots of ways, but no one could work.
Thanks. Worked like a charm.
ReplyDeleteHi I follow the same steps but still i having the same issue. can u help me how can iresolve it
ReplyDeleteYou might be launching old launch configuration files.
DeleteCheck under the folder workspace\.metadata\.plugins\org.eclipse.debug.core\.launches
Make sure there is only one configuration file for each ant build xml file. If you see multiple configuration files, they look like ant-build.xml(1).launch, ant-build.xml(2).launch, etc. Delete the old launch files, then reconfigure using the Ant External Tools Configuration menu. The ant build launch file will be recreated.
Run "eclipse -clean", then delete the duplicate launch files inside Eclipse. Ant->Run As->Select External Tools Configuration, then on the left hand pane, right-click on the ant build configuration->Delete. Double check the launch configuration physical file is deleted.
Then, reconfigure ant launch. Hope this helps.
Been searching for such a remarkable blog like this for a long time.
ReplyDeletetop-10-best-ant-killers
Thanks a lot , it helped me
ReplyDeleteThanks
ReplyDeleteThanks a lot!
ReplyDeletethanks
ReplyDeleteThank you, Thank you, it absolutely helped me.
ReplyDelete