eclipse - 错误: try-with-resources is not supported in -source 1.6

标签 eclipse build syntax-error java-7 try-with-resources

我使用Linux Debian 2.6.32-5-amd64。
我的Eclipse版本:4.2.0
我的Java版本:jdk1.7.0_07

当我构建项目时,出现错误:

[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

我将Compiler合规性级别设置为1.7。怎么了?是问题吗?

最佳答案

您不是在Java 7中编译,而是在Java 6中编译。
项目合规性设置为7,否则try-with-resources将在eclipse编辑器中显示错误。

您应该检查如何构建项目(看起来像ant),并将其配置为在7中编译(使用“-source”参数)。

关于eclipse - 错误: try-with-resources is not supported in -source 1.6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12627004/

相关文章:

python - MySQL 查询 : check the syntax near '?' . 中的语法错误 '?' 来自哪里?

eclipse 月神 CDT : What is a header variant?

android - 无法弄清楚为什么这个内核构建失败

android - 使用支持库时出现错误,指出属性 ""已在 android 中定义

configuration - 在 Xcode 中添加构建配置

ubuntu - 在 ubuntu 中运行 pcl/tools/mesh2pcd.cpp

javascript - 错误行中的Foundation.min.js

syntax-error - UVM 序列体任务给出未知的编译错误

eclipse - 如何防止eclipse-integration-gradle插件将子项目放置在filterResources之间?

java.lang.OutOfMemoryError : PermGen space still exist 错误