
November 7th, 2014, 01:07 PM
|
Registered User
|
|
Join Date: Nov 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
JSPs not compiling with Java 8 in Eclipse Luna
This is my first post, so I hope I'm doing it right.
I'm having the issue where my JSP's compile with the default Eclipse compiler instead of my java 8 compiler.
I've did all the changes from Bug 54461 (link below) without any luck.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54461
Bug 54461 Comment 8 - looks like Nick Williams got it to work somehow.
----------------- Error Message ------------------
Code:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the jsp file: /WEB-INF/jsp/view/viewSessionActivity.jsp
Underscores can only be used with source level 1.7 or greater
3: <%!
4: private static String toString(long timeInterval)
5: {
6: if(timeInterval < 1_000)
7: return "less than one second";
8: if(timeInterval < 60_000)
9: return (timeInterval / 1_000) + " seconds";
---------------------------------------------------
I'm not sure where to change the global Ant compiler properties in the Ant configuration itself (or if it's necessary).
I added the build.compiler property in the Eclipse Ant setup.
Window -> Preferences -> Ant - Runtime - Properties tab.
I tried combinations of:
build.compiler -> modern
build.compiler -> javac1.8
I did this just to try something different, but it didn't change anything:
I added the 3 jar files in the setenv.bat in the Eclipse Ant configuration:
Window -> Preferences -> Ant - Runtime - Global Entries tab.
Running setenv.bat in %tomcat_home%\bin results in:
C:\>cd %tomcat_home%\bin
C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.3\bin>.\setenv.bat
C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.3\bin>echo %classpath%
C:\Program Files\Java\jdk1.8.0_05\lib\tools.jar;C:\Program Files\Java\apache-ant-1.9.2\lib\ant.jar;C:\Program Files\Java\apache-ant-1.9.2\lib\ant-launcher.jar
My tomcat web.xml configurations look like this:
Code:
<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>
<!-- I added this from book and bug 54461 -->
<init-param>
<param-name>compiler</param-name>
<param-value>modern</param-value>
</init-param>
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.8</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.8</param-value>
</init-param>
<init-param>
<param-name>suppressSmap</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
Bug 54461 - Comment 6
I tried only changing this parameter from above:
. . . . .
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.7</param-value>
</init-param>
. . . . .
Any suggestions would be appreciated.
|