在Eclipse中编写Java 7 [英] Programming Java 7 in Eclipse

查看:156
本文介绍了在Eclipse中编写Java 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了 JDK 7 Eclipse 3.6M6 。然后,我在Eclipse中添加了JRE 7作为新的JRE执行环境,并将编译器的合规性级别设置为Java 7.我可以使用 javac 它附带JDK 7.

I installed JDK 7 and Eclipse 3.6M6. Then, I added JRE 7 as a new JRE execution environment in Eclipse, and set the compiler compliance level to Java 7. I can compile the following piece of code through command line using the javac that comes with JDK 7.

import java.util.HashMap;
import java.util.Map;

public class Try {

    public static void main(String[] args) {
        Map<Integer, String> map = new HashMap<>();
    }
}

但是,Eclipse会提供以下错误消息。 p>

But, Eclipse gives the following error messages.


类型为HashMap的参数数不正确;它不能被参数参数Try.java / TryJava7 / src第7行Java问题

Incorrect number of arguments for type HashMap; it cannot be parameterized with arguments Try.java /TryJava7/src line 7 Java Problem

令牌上的语法错误<,?这个标记之后的预期Try.java / TryJava7 / src第7行Java问题

Syntax error on token "<", ? expected after this token Try.java /TryJava7/src line 7 Java Problem

即使我已经设置了编译器的合规级别到Java 7,看起来Eclipse不懂Java7语法。可以在Eclipse中玩Java 7吗?

Even though I've set the compliance level of the compiler to Java 7, it looks like Eclipse doesn't understand Java7 syntax yet. Is it possible to play with Java 7 in Eclipse?

以下是 .classpath 的内容。 p>

The following is the content of .classpath.

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
  <classpathentry kind="src" path="src"/>
  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
  <classpathentry kind="output" path="bin"/>
</classpath>

而且,以下是 .settings / org.eclipse的内容。 jdt.core.prefs

eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7


推荐答案

请参阅 http:// wiki .eclipse.org / JDT_Core / Java7 http://wiki.eclipse.org/PDE/API_Tools/Java7 Bug 288548 用于持续支持Eclipse for Java 7.请参阅 http://wiki.eclipse.org/JDT/Eclipse_Java_7_Support_%28BETA%29 ,了解如何评估Eclipse中的Java 7。

See http://wiki.eclipse.org/JDT_Core/Java7, http://wiki.eclipse.org/PDE/API_Tools/Java7 and Bug 288548 for the ongoing support of Eclipse for Java 7. And see http://wiki.eclipse.org/JDT/Eclipse_Java_7_Support_%28BETA%29 for instructions on how to evaluate Java 7 in Eclipse.

更新1: BETA_JAVA7 分支已合并到 HEAD R3_7_maintenance (请参阅 eclipse-dev存档)。

UPDATE 1: The BETA_JAVA7 branch has been merged to HEAD and R3_7_maintenance (See the eclipse-dev archive).

更新2: Eclipse 3.7.1(Indigo SR1)支持Java 7

这篇关于在Eclipse中编写Java 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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