This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Change Tomcat's JDK Version Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Change Tomcat Watch "Change Tomcat New topic
Author

Change Tomcat's JDK Version

junchen liu
Greenhorn

Joined: Feb 19, 2008
Posts: 26
I use Tomcat 5.5.9 , and the JVM it uses java 5
how can I change the Java version to 6.0?
is there any configuration file which I can edit,
I tried server.xml or catalina.property file, they seem
not the right one. help please

Regards
benjamin muktesh
Greenhorn

Joined: Jul 01, 2008
Posts: 24
Go to tomcat/bin and modify the JAVA_HOME parmater in catalina.sh (for linux/unix) or catalina.bat (for windows)
Bert Bertens
Greenhorn

Joined: Feb 16, 2010
Posts: 14
benjamin muktesh wrote:Go to tomcat/bin and modify the JAVA_HOME parmater in catalina.sh (for linux/unix) or catalina.bat (for windows)

Ive been searching for days for this solution,
I've had this error and now it's solved:
javax.servlet.ServletException: Bad version number in .class file
for my Java Server Faces JSF beans which all gave errors.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
Which JRE version and which JSF version are you using? JSF 1.2 requires at least Java 5 (since it's part of JEE 5), while JSF 2.0 requires Java 6 (since it's part of JEE 6).

Is there a class file version number given in the error message? Should be a number around 50.


Ping & DNS - my free Android networking tools app
Bert Bertens
Greenhorn

Joined: Feb 16, 2010
Posts: 14
Ulf Dittmer wrote:Which JRE version and which JSF version are you using? JSF 1.2 requires at least Java 5 (since it's part of JEE 5), while JSF 2.0 requires Java 6 (since it's part of JEE 6).

Is there a class file version number given in the error message? Should be a number around 50.


No I meant with my post that my problem was already solved. After googling my error I found that there's a JDK difference between Tomcat and Maven, so I just googled how to change Tomcat's JDK version and found this thread. But I had been searching long before I realised that the JDK difference was the problem (I had two JDK's on my pc and the system environment variable pointed to the outdated JDK, which Tomcat uses) so I thought I'd post the error message here so Googlers might end up here.
Shashank Sharma
Ranch Hand

Joined: Sep 27, 2006
Posts: 91

SEVERE: Servlet.service() for servlet RestServlet threw exception
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1815)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.restlet.engine.Engine.loadClass(Engine.java:242)



Hello I am struggling with the same error.
My server side application is using jdk 1.5 specification.
when I build it through eclipse 1.5 compliance setting and exporting it as a war file to the server tomcat web apps folder. I am getting the same error.
I have build the application using dynamic web project 2.4.
In project facets section I have following points checked.

1.Dynamic web module :2.4
2.Java :1.5

Will my windows environment variable affect the eclipse build settings??



 
jQuery in Action, 2nd edition
 
subject: Change Tomcat's JDK Version
 
Similar Threads
java web start security
BEA Weblogic to FORCE_SHUTDOWN STATE , duirng Start up with Eclipse in Debug Mde
problem with installing eclipse
what changes have to be made while migrating from 1.4 mysql jdbc to 1.5 jdbc
please can you clear my doubt?(immediately)