java - 无法在 JDK 7 中打开 String 类型

标签 java string java-7

我安装了 JDK 7 并使用了 tomcat 7。

我现在在字符串变量上使用 switch 时遇到此错误,

Cannot switch on a value of type String for source level below 1.7

我还为 JDK 7 设置了类路径,但我没有安装 JDK 6。如何解决?

最佳答案

默认的 Tomcat JSP 编译器将编译为 Java 1.6。 查看Tomcat documentation了解如何指定 JSP 页面使用哪个编译器。

查看这些参数:

compiler - Which compiler Ant should use to compile JSP pages. The valid values for this are the same as for the compiler attribute of Ant's javac task. If the value is not set, then the default Eclipse JDT Java compiler will be used instead of using Ant. There is no default value. If this attribute is set then setenv.[sh|bat] should be used to add ant.jar, ant-launcher.jar and tools.jar to the CLASSPATH environment variable.

compilerSourceVM - What JDK version are the source files compatible with? (Default value: 1.6)

compilerTargetVM - What JDK version are the generated files compatible with? (Default value: 1.6)

关于java - 无法在 JDK 7 中打开 String 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17545720/

相关文章:

java - 为什么 getWindow() 无法解决?

java - Oracle SQL Developer 在尝试查看表时没有响应(或建议使用 Oracle Mac 客户端)

java - 在 try catch 中使用 Throwable 和 Exception 的区别

python - 如何从一串数字和逗号中挑选出数百万?

java - 在日期字段 : Java 中不能使用超过 "2038"的年份

java - 推土机 : String-To-Date Field Level Mapping for a List

java - Spark DataFrame 和重命名多列 (Java)

java - Gradle将命令行参数传递给子项目运行任务

python - 从 CamelCase 生成详细名称

JavaScript,字符串 : test string for presence of sub-string that includes an asterisk (*)