How can I use Java 7 with Eclipse Indigo 3.7.1

↘锁芯ラ 提交于 2019-12-07 05:41:31

问题


From what I understand Eclipse Indigo 3.7.1 should now have support for Java 7.

I downloaded Eclipse 3.7.1. and JDK 1.7.0 and added JRE7 in the settings in Eclipse. Then I created a new project using JRE7 and wrote a short Java 7 program:

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;
        }
    }
}

But I get an error when I try to use a String in a Switch statement. 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? Is there any settings in Eclipse I need to change?


回答1:


You also have to change the compiler compliance settings under "Preferences | Java | Compiler | JDK Compliance." Setting the JDK for the project only sets the libraries to compile against and the JDK used to run the project.



来源:https://stackoverflow.com/questions/7545560/how-can-i-use-java-7-with-eclipse-indigo-3-7-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!