1

I installed JDK 7 and using tomcat 7.

I'm now getting this error when using switch on a String variable,

Cannot switch on a value of type String for source level below 1.7

I also set my classpath for JDK 7, i dnt have JDK 6 installed. How to resolve this?

K Karan
  • 51
  • 6

2 Answers2

4

The default Tomcat JSP compiler will compile to Java 1.6. Check out the Tomcat documentation for how to specify which compiler is used for JSP pages.

Look at these parameters :

compiler - Which compiler Ant should use to compile JSP pages. The valid values for this are the same as for the compiler attribute of Ant's javac task. If the value is not set, then the default Eclipse JDT Java compiler will be used instead of using Ant. There is no default value. If this attribute is set then setenv.[sh|bat] should be used to add ant.jar, ant-launcher.jar and tools.jar to the CLASSPATH environment variable.

compilerSourceVM - What JDK version are the source files compatible with? (Default value: 1.6)

compilerTargetVM - What JDK version are the generated files compatible with? (Default value: 1.6)

Community
  • 1
  • 1
AllTooSir
  • 48,828
  • 16
  • 130
  • 164
  • I opened 'monitor tomcat' and opened java tab there JVM is set to "C:\Program Files\Java\jre7\bin\client\jvm.dll" – K Karan Jul 09 '13 at 10:30
  • Look [here](http://stackoverflow.com/questions/11000497/how-to-configure-tomcat-to-use-java-7). – AllTooSir Jul 09 '13 at 10:31
  • Ya the JVM is already set to "C:\Program Files\Java\jre7\bin\client\jvm.dll" but still facing the same problem. – K Karan Jul 09 '13 at 10:34
1

This link might help you:

At the moment, you can use Java 7 with Servlets. You can use it with JSPs as long as you configure the JSP Engine to use javac as the compiler. By default, the JSP Engine is pre-configured to use the Eclipse compiler and the current version does not support Java 7.

Michael Lang
  • 3,902
  • 1
  • 23
  • 37