Diamond operator(<>) not working in java 1.7

前端 未结 3 1536
感动是毒
感动是毒 2020-12-21 15:39

I have the following error for compiling a jsp file:

\'<>\' operator is not allowed for source level below 1.7

I\'m using

相关标签:
3条回答
  • 2020-12-21 16:05

    So the only way it seems now is that your application server, eg tomcat is configured for jdk version lower than 1.7. check what version of java is being pointed by JAVA_HOME environment variable on your system.If you correct that, it should solve your problem.

    0 讨论(0)
  • 2020-12-21 16:22

    Check the following areas within Eclipse:

    1. Right Click Project > Properties > Project Facets > Java > Version 1.7

    2. Right Click Project > Properties > Java Build Path > Libraries > JRE Library should be 1.7

    3. Right Click Project > Properties > Java Compiler > Compiler compliance level

    4. Window > Preferences > Server > Runtime Environment > Select the Server > Edit > Ensure JRE is set to 1.7

    0 讨论(0)
  • 2020-12-21 16:28

    I know it's been over 2 years since this thread was last active but in case someone is looking for an answer and the above checks don't solve it: it's because the compiler that your tomcat is running is older than 1.7. One way to solve this is to 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>
    

    Source

    0 讨论(0)
提交回复
热议问题