Mariusz Galler
Mariusz Galler

Reputation: 1

error: try-with-resources is not supported in -source 1.6

I using Linux Debian 2.6.32-5-amd64. My version Eclipse: 4.2.0 My version Java: jdk1.7.0_07

When I build my project then I getting error:

[javac] <myPath>file.java:66: error: try-with-resources is not supported in -source 1.6
[javac]         try(Scanner scanner = new Scanner(new File(path))){
[javac]            ^
[javac]   (use -source 7 or higher to enable try-with-resources)
[javac] 1 error

I have Compiler compliance level set to 1.7. What is wrong? Were is the problem?

Upvotes: 0

Views: 1485

Answers (1)

mkhelif
mkhelif

Reputation: 1559

You are not compiling in java 7 but in java 6. The project compliance is set to 7 otherwise the try-with-resources would show an error in eclipse editor.

You should check how you are building your project (looks like ant) and configure it to compile in 7 (using the "-source" parameter).

Upvotes: 1

Related Questions