How can I use Java 7 with Eclipse Indigo 3.7.1
Asked Answered
C

1

5

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

Start a Java 7 project

But I get an error when I try to use a String in a Switch statement. The error in Content assist looks like this:

Content assist error

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?

Caducous answered 25/9, 2011 at 12:45 Comment(0)
C
10

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.

Cowman answered 25/9, 2011 at 12:47 Comment(3)
+1 Also, you might want to use a JDK for development instead of a JRE.Fantasize
Hmmm. I thought it was indeed done, but maybe not: wiki.eclipse.org/JDT_Core/Java7Cowman
@Ernest: You are right, I started Eclipse 3.7.0 when I tested. But now in 3.7.1 it works fine. Thanks!Caducous

© 2022 - 2024 — McMap. All rights reserved.