使用 Java 1.6 在 Eclipse Mars 上运行 Ant [英] Run Ant on Eclipse Mars with Java 1.6

查看:38
本文介绍了使用 Java 1.6 在 Eclipse Mars 上运行 Ant的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了最新版本的 Eclipse (Mars) 并在 eclipse.ini 文件中将所需的 Java 版本更改为 1.6,因为我的项目使用 Java 1.6.

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.

我在 Eclipse 中配置了已安装的 JRE 以使用 Java 1.6.但是当我尝试执行我的 ant 目标时,它会产生一个错误:

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

不支持低于 1.7 的 JRE 版本.

JRE version less than 1.7 is not supported.

是否有任何解决方法可以在 Mars 版本中使用 Java 1.6,因为我目前无法升级到 Java 1.7?

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?

推荐答案

我在升级到 Eclipse Mars 后遇到了同样的问题.

I faced the same problem after upgrading to Eclipse Mars.

我通过将项目的外部工具配置的运行环境更改为JDK7解决了这个问题.

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

我假设您知道如何将 JDK7 添加到您在 eclipse 中安装的 jre

打开外部工具配置...,然后将 JRE 更改为 JDK 1.7

然后更改JRE

但这会产生另一个问题,编译后的 jar 将在 JDK 7 中,这不适用于具有 JDK6 的生产服务器.

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

要解决这个问题,只需将任务中的目标属性更改为1.6

<javac target="1.6">

根据@dag 和@Chris 的建议,这里是更新的 ant javac 任务.

这篇关于使用 Java 1.6 在 Eclipse Mars 上运行 Ant的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆