简体   繁体   English

如何在Eclipse Indigo 3.7.1中使用Java 7

[英]How can I use Java 7 with Eclipse Indigo 3.7.1

From what I understand Eclipse Indigo 3.7.1 should now have support for Java 7. 据我所知, Eclipse Indigo 3.7.1现在应该支持Java 7。

I downloaded Eclipse 3.7.1. 我下载了Eclipse 3.7.1。 and JDK 1.7.0 and added JRE7 in the settings in Eclipse. 和JDK 1.7.0并在Eclipse的设置中添加了JRE7。 Then I created a new project using JRE7 and wrote a short Java 7 program: 然后我使用JRE7创建了一个新项目并编写了一个简短的Java 7程序:

public class Test7 {

    public static void main(String[] args) {
        String k = "Hello";
        switch(k) {
        case "World": System.out.println("World Hello");
            break;
        case "Hello": System.out.println("Hello World");
            break;
        }
    }
}

启动Java 7项目

But I get an error when I try to use a String in a Switch statement. 但是当我尝试在Switch语句中使用String时出现错误。 The error in Content assist looks like this: 内容辅助中的错误如下所示:

内容辅助错误

Have I done anything wrong or doesn't Eclipse 3.7.1 have support for Java 7 yet? 我做错了什么或Eclipse 3.7.1是否支持Java 7? Is there any settings in Eclipse I need to change? 我需要更改Eclipse中的任何设置吗?

You also have to change the compiler compliance settings under "Preferences | Java | Compiler | JDK Compliance." 您还必须在“首选项| Java |编译器| JDK合规性”下更改编译器合规性设置。 Setting the JDK for the project only sets the libraries to compile against and the JDK used to run the project. 为项目设置JDK仅设置要编译的库和用于运行项目的JDK。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM