CheeHow
CheeHow

Reputation: 925

Using try-with-resources in Netbeans

I have a try-catch statement in a Java servlet class. Netbeans shows an error on this:

try-with-resources is not supported in -source 1.6 (use -source 7 or higher to enable try-with-resources)

How can I get rid of this error?

Upvotes: 6

Views: 5514

Answers (2)

JAsdrubal
JAsdrubal

Reputation: 1

Ok it didn't work for me. Because in "Source/Binary Format:" there isn't "JDK 7".

My solution was: Right click on project > Properties > Libraries > Manage Plataforms > Add Plataform, and choose your "jdk1.7.0_45" directory click on NEXT put a name "JDK 1.7" and FINISH.

Now you can modify your source format: Right click on project > Properties > Sources > Source/Binary Format: JDK 7 > OK.

Upvotes: 0

XP1
XP1

Reputation: 7193

It looks like you found my thread from the NetBeans forums, in which I posted the solution:

I got the error to go away.

Right click on project > Properties > Sources > Source/Binary Format: JDK 7 > OK.

Source:

Upvotes: 5

Related Questions