问题描述
根据我的了解现在应该支持Java 7。
From what I understand Eclipse Indigo 3.7.1 should now have support for Java 7.
我下载了Eclipse 3.7.1。和JDK 1.7.0,并在Eclipse的设置中添加了JRE7。然后我使用JRE7创建了一个新项目,并写了一个简短的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;
}
}
}
但是当我尝试使用时会收到错误switch语句中的字符串。内容辅助中的错误如下所示:
But I get an error when I try to use a String in a Switch statement. The error in Content assist looks like this:
我做错了什么或者没有Eclipse 3.7.1支持Java 7?您需要更改Eclipse中的任何设置?
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?
推荐答案
您还必须更改Preferences | Java |编译器| JDK合规性。设置项目的JDK只设置要编译的库和用于运行项目的JDK。
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.
这篇关于如何使用Java 7与Eclipse Indigo 3.7.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!