2

I have the following error for compiling a jsp file:

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

I'm using jdk 1.7.x and eclipse Kepler Also I have set 1.7 as compliance level in project preferences in Eclipse, still the code is not working

Should I add any other config?

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
nj-ath
  • 3,028
  • 2
  • 25
  • 41

3 Answers3

9

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

Kevin Bowersox
  • 93,289
  • 19
  • 159
  • 189
  • Thanks for the great answer, but it still isn't working.. All the above mentioned properties are set to 1.7.0_25 – nj-ath Apr 03 '14 at 10:51
  • Just to shed some light on things, if you place the code inside a class as opposed to the JSP does it complain? – Kevin Bowersox Apr 03 '14 at 10:56
  • Also make sure that you are pointing to the right JDK. `Window > Preferences > Java > Installed JREs`. Just ensure that it is pointing to the folder with 1.7 installed. – Kevin Bowersox Apr 03 '14 at 11:01
  • Working fine with a simple class.. Problem persists with JSP files though – nj-ath Apr 03 '14 at 11:01
  • 1
    I think the application server is running on a previous version of the JRE/JDK. Do you have an older version set on your classpath or specified for java home? – Kevin Bowersox Apr 03 '14 at 11:06
0

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.

nanosoft
  • 2,913
  • 4
  • 41
  • 61
0

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

Community
  • 1
  • 1
Randy
  • 295
  • 1
  • 9