Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
239 views
in Technique[技术] by (71.8m points)

java - IntelliJ IDE gives error when using Try-Catch with Resources

I am attempting to use JDK 7's "try-catch with resources" statement; IntelliJ highlights my resource line, saying

Try-with-resources are not supported at this language level.

When I try to compile, I get:

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

I checked that try-with-resources is enabled for my current project, and that my project is using JDK 7 (Library: C:Program FilesJavajdk1.7.0_11). Any ideas? I can't figure out what option to change (if that's even the issue).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Click on the File menu, open Project Structure, then under "Settings" there should be "Project". Within that tab, there'll be an SDK Settings option which specifies the language version you want to use.

See the JetBrains help page for more details ("Project language level").


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...