Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Ant on Eclipse Mars with Java 1.6

Tags:

I downloaded the latest release of Eclipse (Mars) and changed the required Java version to 1.6 in eclipse.ini file as my project uses Java 1.6.

I configured installed JREs inside Eclipse to use Java 1.6. But when I try to execute my ant target it creates an error:

JRE version less than 1.7 is not supported.

Is there any workaround to use Java 1.6 in Mars version as I'm unable to upgrade to Java 1.7 at the moment?

like image 289
Chandika Gunawardhana Avatar asked Jun 25 '15 14:06

Chandika Gunawardhana


2 Answers

I faced the same problem after upgrading to Eclipse Mars.

I solved this by changing the runtime environment of the external tool configuration of the project to JDK7.

I assume you know how to add JDK7 to your installed jre in eclipse

Open External Tools Configurations... and then change the JRE to JDK 1.7

Open External Tools Configurations

Then change the JRE

Change JRE

But this will create another problem, the compiled jar will be in JDK 7 and this will not work on production servers with JDK6.

To solve this, simply change the target attribute in the task to be 1.6

<javac target="1.6">

Change Task target to 1.6

As per suggested from @dag and @Chris, Here is updated ant javac task. enter image description here

like image 82
Amr ElAdawy Avatar answered Oct 01 '22 15:10

Amr ElAdawy


We fixed the problem for us using a patched Ant plugin. For Eclipse Neon, also see this link as is noted in the comments on the first page.

like image 44
rjahn Avatar answered Oct 01 '22 13:10

rjahn