I have Java 1.6 and Tomcat 5.5 installed on my system.
But Tomcat 5.5 accesses Java 1.5 and hence as the outcome I get the error Bad version number in .class file
while executing java code with JSP.
How can I change the Tomcat version to Java 1.6?
UPDATE
I tried changing the JVM that the tomcat5w.exe is pointing to the version 1.6 and now I am out of the Bad version in .class file
error. But now, I get the following error.
exception org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:498) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) root cause java.lang.NullPointerException myfirst.SearchLink.checkURL(SearchLink.java:20) org.apache.jsp.Test_jsp._jspService(Test_jsp.java:52) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259) javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
What might be the root cause?
ya java -version says it is java 1.7.
High level steps: Project Properties / Target Runtime / select the Target runtime. Project Properties / Java Build Paths / Edit Apache Tomcat entry and select the run time to add to classpath. Project Properties / Project Facets / Select Dynamic Web Module and change the version.
Using setenv file. In CATALINA_BASE/bin directory open or create file named setenv.sh and put JAVA_HOME=/usr/lib/jvm/openjdk-8-jdk in it. This will change it only for your tomcat. Please note to change it to the JDK/JRE you want to use.
When you open catalina.sh / catalina.bat, you can see :
Environment Variable Prequisites
JAVA_HOME Must point at your Java Development Kit installation.
So, set your environment variable JAVA_HOME
to point to Java 6. Also make sure JRE_HOME
is pointing to the same target, if it is set.
Update: since you are on Windows, see here for how to manage your environment variables
You can change the JDK or JRE location using the following steps:
[tomcat-home]\bin
directory. c:\tomcat8\bin
Tomcat8W //ES//Tomcat8
note: in Apache TomEE same steps, but step (3) the command must be: TomEE //ES
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With