Diamond operator(<>) not working in java 1.7

房东的猫 提交于 2019-11-29 15:47:41

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

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.

Randy

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!