1. Download J2SE 5.0 form Java/Sun site and install.
2. Change Tomcat’s classpath to use the new compiler:
– On Windows, this can be done by opening ‘Configure Tomcat’ from the Start Menu/Apache Tomcat 5.5 menu, clicking on the ‘Java’ subtab and changing the JVM location.
– On Linux, you can do this by just changign the JAVA_HOME env var for the user that starts/stops tomcat.
3. In Eclipse, Open Window->Preferences, then click on Java/Compiler in the preferences menu. Change the ‘Compiler Compliance Level’ to 5.0
4) Check your build.xml (assuming you’re using ant to build) and make sure that you have the following parameter set correctly: source=”1.5″
5) Do a full build and test your app!
Next, if you’d like to use 5.o features in your JSP files:
6) add tools.jar from your JAVA_HOME/lib directory to TOMCAT_HOME/common/lib
7) Remove jasper-compiler-jdt.jar from the TOMCAT_HOME/common/lib dir and replace with ant.jar. I used Version 1.6.5 available from the Ant/Apache website.
8) You’ll need to edit your web.xml file in TOMCAT_HOME/conf and add the params in red.
<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>compilerSourceVM</param-name>
<param-value>1.5</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.5</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
9) Restart tomcat (Better safe than sorry)
Done!




















Leave a Reply