我使用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我将编译器合规性级别设置为1.7。怎么啦?问题出在哪里?
发布于 2012-10-08 16:40:42
你不是用java7编译,而是用java6编译。项目合规性设置为7,否则try-with-resources会在eclipse编辑器中显示错误。
您应该检查您是如何构建项目的(看起来像ant),并将其配置为在7中编译(使用"-source“参数)。
https://stackoverflow.com/questions/12627004
复制相似问题