这很容易:您使用比Tomcat下面的Java运行时更高的Java编译器来编译应用程序。
更新资料
Java编译器javac支持选项
-source release Specifies the version of source pre accepted. The following values for release are allowed: 1.3 the compiler does not support assertions, generics, or other language features introduced after JDK 1.3. 1.4 the compiler accepts pre containing assertions, which were introduced in JDK 1.4. 1.5 the compiler accepts pre containing generics and other language features introduced in JDK 5. The compiler defaults to the version 5 behavior if the -source flag is not used. 5 Synonym for 1.5
…甚至更重要的是,
-target version Generate class files that will work on VMs with the specified version. The default is to generate class files to be compatible with the JDK 5 VM. When the -source 1.4 or lower option is used, the default target is 1.4. The versions supported by javac are: 1.1 Generate class files that will run on VMs in JDK 1.1 and later. 1.2 Generate class files that will run on VMs in JDK 1.2 and later, but will not run on 1.1 VMs. 1.3 Generate class files that will run on VMs in JDK 1.3 and later, but will not run on 1.1 or 1.2 VMs. 1.4 Generate class files that will run on VMs in JDK 1.4 and later, but will not run on 1.1, 1.2 or 1.3 VMs. 1.5 Generate class files that are compatible only with JDK 5 VMs. 5 Synonym for 1.5
…这将允许您为特定版本的JVM编译代码。
换句话说,您可以继续使用1.6编译器,只需向其抛出这些选项,即可使其生成Tomcat能够处理的1.5代码。



