使用Try-Catch with Resources时,IntelliJ IDE会出错 [英] IntelliJ IDE gives error when using Try-Catch with Resources

查看:212
本文介绍了使用Try-Catch with Resources时,IntelliJ IDE会出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JDK 7的try-catch with resources语句; IntelliJ突出显示我的资源行,说

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- -source 1.6
不支持with-resources(使用-source 7或更高版本来启用try-with-resources)

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



<我检查了我的当前项目是否启用了try-with-resources,我的项目是使用JDK 7(Library:C:\Program Files \ Java \\\\\\\\\\\\有任何想法吗?我无法弄清楚要改变什么选项(如果这甚至是问题)。

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

推荐答案

点击文件菜单,打开项目结构,然后在设置下应该有项目。在该选项卡中,将有一个SDK设置选项,用于指定您要使用的语言版本。

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.

请参阅 JetBrains帮助页面了解更多详情(项目语言级别)。

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

这篇关于使用Try-Catch with Resources时,IntelliJ IDE会出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆