4

I have Java 7 running on my mac:

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

Project was created using

enter image description here

Project properties confirm, i am on Java 7

enter image description here

Default system Java is 7

enter image description here

The following however results in syntax error

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

Eclipse is complaining with Syntax error on token "_234", delete this token

10
  • What happens on the commandline when you run javac -version? Commented Jul 21, 2012 at 21:22
  • Comes back with java version "1.7.0_05" Commented Jul 21, 2012 at 21:26
  • What is the error message exactly? Commented Jul 21, 2012 at 21:30
  • In Eclipse Syntax error on token "_234", delete this token Commented Jul 21, 2012 at 21:31
  • Negative, this in fact is the first and only line in my Main class. Updated question Commented Jul 21, 2012 at 21:33

2 Answers 2

5

On Eclipse's Project|Properties dialog, there two entities Java Build Path and Java Compiler. The former will tell you what classes are used during the build, and you may have a Java 7 JRE listed there. The latter, however, is the compiler that will be used to compile your code. It is possible to have Eclipse use a Java 6 compiler even with a Java 7 JRE on the build path.

My guess is that you are using Helios, not Indigo. See Programming Java 7 in Eclipse

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you. Indeed this seems to be the case. I don't have 1.7 as an option on my Java Compiler section. How may i get it to appear there?
Are you using Helios or Indigo?
Downloading Juno now. Of all the things, updating Eclipse itself did not occur to me
5

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).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.