Java 7 syntax error

I have Java 7 running on my mac:

System.out.println(System.getProperty("java.version")); // prints 1.7.0_05 

The project was created using

enter image description here

Project Properties Confirm I'm in Java 7

enter image description here

Java default system is 7

enter image description here

The following leads to a syntax error

 public static void main(String[] args) { // Underscores in Numeric Litarals are ok here int i = 11_234; } 

Eclipse complains about Syntax error on token "_234", delete this token

+4
source share
2 answers

The Eclipse Project | Properties dialog box contains two Java Build Path and Java Compiler objects. The first will tell you which classes are used during the build, and you may have a Java JRE JRE specified. The latter, however, is the compiler that will be used to compile your code. Perhaps Eclipse uses the Java 6 compiler even with the Java JRE in the build path.

I assume that you are using Helios, not Indigo. See Java 7 Programming in Eclipse

+5
source

Make sure your version of Eclipse is 3.7.1 (this is Eclipse 3.7 Maintenance Build) or higher (see JDT / Eclipse Java 7 Support ) and that you have registered Java 7 with Eclipse (see Eclipse and Java 7 ).

+5
source

All Articles