我从命令行在 unix 中运行一个简单的 java 程序时收到此编译错误:
ERROR in test.java (at line 92)
List fileNames = new ArrayList<String>();
^^^^^^
Syntax error, parameterized types are only available if source level is 5.0
同样的问题Java - Iterator: "Syntax error, parameterized types are only available if source level is 5.0"的答案是泛型是在 java 版本 > 5.0 中引入的,但是当我从命令行执行 java -version 时,它显示:
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.6)
合规版本默认设置为 1.4:
Compliance options:
-1.3 use 1.3 compliance level (implicit -source 1.3
-target 1.1)
-1.4 + use 1.4 compliance level (implicit -source 1.3
-target 1.2)
-1.5 use 1.5 compliance level (implicit -source 1.5
-target 1.5)
-1.6 use 1.6 compliance level (implicit -source 1.6
-target 1.6)
-source <version> set source level: 1.3 to 1.6 (or 5, 5.0, 6 or 6.0)
-target <version> set classfile target level: 1.1 to 1.6 (or 5, 5.0, 6 or
6.0)
如何从命令行将其更改为 1.5。