IntelliJ错误 - 在-source 1.6错误中不支持java:try-with-resources。即使在项目设置中,也选择了1.7 JDK [英] IntelliJ error - java: try-with-resources is not supported in -source 1.6 error. Even though in project settings 1.7 JDK is selected

查看:2400
本文介绍了IntelliJ错误 - 在-source 1.6错误中不支持java:try-with-resources。即使在项目设置中,也选择了1.7 JDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在文件 - >项目结构 - > SDKs我有1.7 jdk,但我仍然收到此错误:

Under File -> Project Structure -> SDKs i have 1.7 jdk but i still get this error:

added.java:不支持try-with-resources in -source 1.6
(使用-source 7或更高版本来启用资源试用)

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

我已重新启动IDE但无效

I have restarted IDE but to no avail

推荐答案

较新的JVM允许您使用较低JVM版本的编译器版本编译代码。例如,JDK 1.7允许您使用1.5编译器编译代码。

Newer JVMs allow you to compile your code using compiler versions of lower JVM versions. For example, JDK 1.7 will allow you to compile your code using the 1.5 compiler.

请参阅此处的交叉编译部分 http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html

See the "Cross compilation section" here http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html

您在Intellij中需要做的是转到文件 - > 项目结构 - > < kbd> Project 并选择Project SDK为1.7,Project Language Level为7.0

What you need to do in Intellij, is to go to File -> Project Structure -> Project and select the "Project SDK" as 1.7 and the "Project Language Level" as 7.0

这篇关于IntelliJ错误 - 在-source 1.6错误中不支持java:try-with-resources。即使在项目设置中,也选择了1.7 JDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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