如何更改tomcat编译器 [英] How to change tomcat compiler
问题描述
我正在尝试使用新的Java 7字符串开关功能.
I'm trying to use the new Java 7 switch on strings feature.
但是Tomcat没有合作.
But Tomcat is not cooperating.
我已经确定tomcat在Java 7下运行,但是看来它没有在Java 7下编译.
I've made sure that tomcat is running under java 7 but it seems that it's not compiling under it.
我已将以下内容添加到web.xml文件中的jsp servlet条目下
I've added the following to the web.xml file, under the jsp servlet entry
<init-param>
<param-name>compiler</param-name>
<param-value>C:/Program Files/Java/jdk1.7.0/bin/javac.exe</param-value>
</init-param>
但它似乎并不能解决问题.
but it doesn't seem to do the trick.
任何提示将不胜感激.
推荐答案
我们正在运行Tomcat 6,但存在相同的问题.我们的解决方案是:
We are running Tomcat 6 and had the same problem. Our solution was to:
- 将
tomcat/lib/ecj-3.3.1.jar
替换为ecj-3.7.2.jar
(可取自最新的Tomcat 7版本); -
将此添加到
tomcat/conf/web.xml
- replace
tomcat/lib/ecj-3.3.1.jar
withecj-3.7.2.jar
(can be taken from the latest Tomcat 7 release); add this to
tomcat/conf/web.xml
...
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<init-param> <!-- this should be added -->
<param-name>compilerSourceVM</param-name>
<param-value>1.7</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.7</param-value>
</init-param> <!-- last added line -->
<load-on-startup>3</load-on-startup>
</servlet>
当然,更简单的选择是安装Tomcat 7,但这可能并不是每个人的选择.
The simpler alternative is, of course, to install Tomcat 7 but this might not be an option for everyone.
这篇关于如何更改tomcat编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!