How to change tomcat compiler

后端 未结 5 1445
醉酒成梦
醉酒成梦 2020-12-10 03:03

I\'m trying to use the new Java 7 switch on strings feature.

But Tomcat is not cooperating.

I\'ve made sure that tomcat is running under java 7 but it seems

5条回答
  •  鱼传尺愫
    2020-12-10 03:41

    We are running Tomcat 6 and had the same problem. Our solution was to:

    • replace tomcat/lib/ecj-3.3.1.jar with ecj-3.7.2.jar (can be taken from the latest Tomcat 7 release);
    • add this to tomcat/conf/web.xml

      ...
      
        jsp
        org.apache.jasper.servlet.JspServlet
        
            fork
            false
        
        
            xpoweredBy
            false
        
                                            
            compilerSourceVM
            1.7
        
        
            compilerTargetVM
            1.7
                                           
        3
      
      

    The simpler alternative is, of course, to install Tomcat 7 but this might not be an option for everyone.

提交回复
热议问题