• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

java.lang.UnsupportedClassVersionError: Bad version number in .class file

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having an issue running my servlet. Can anyone help me figure out why I am getting the bad version error? Below also are my servlet code and my path and classpath info. I am using Orion 2.0.7 for the app server.

I am receiving the following:

500 Internal Server Error
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at com.evermind[Orion/2.0.7 (build 11273)]._as.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.evermind[Orion/2.0.7 (build 11273)]._ay._lye(Unknown Source)
at com.evermind[Orion/2.0.7 (build 11273)]._ay._cbd(Unknown Source)
at com.evermind[Orion/2.0.7 (build 11273)]._ay._nlc(Unknown Source)
at com.evermind[Orion/2.0.7 (build 11273)]._ax._lsc(Unknown Source)
at com.evermind[Orion/2.0.7 (build 11273)]._ax._uab(Unknown Source)
at com.evermind[Orion/2.0.7 (build 11273)]._bf.run(Unknown Source)

Can anyone help me figure out why I am getting the bad version?


Below is my servlet and my path and classpath info that may help.

My servlet is BeeServlet copied directly from the Cattle Drive.

import java.io.* ;
import javax.servlet.http.* ;

public class BeeServlet extends HttpServlet
{

public void doGet( HttpServletRequest request , HttpServletResponse response )
{
response.setContentType("text/html");
try
{
PrintWriter out = response.getWriter();
out.println( "a-buzz-buzz ..." );
out.close();
}
catch( Exception e )
{
System.out.println( "cannot get writer: " + e );
}
}

}


The follow are my path and classpath configuration:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Owner>cd c:\java

C:\java>cd c:\orion

C:\orion>echo %path%
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Sun\SDK\bin;c:\Sun\SD
K\jdk\bin;c:\Sun\SDK\jdk\jre\bin;C:\Sun\AppServer\bin

C:\orion>echo %classpath%
.;c:\Sun\SDK\lib\j2ee.jar;c:\StudentWork\jr.jar

C:\orion>java -jar orion.jar
Orion/2.0.7 initialized

As you can see I'm using Orion 2.0.7 for the app server.


If I am lacking any other info, please let me know.

Thanks
Jim

 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
UnsupportedClassVersionError means that the class that you are trying to use was compiled in a version of Java that the Java Runtime doesn't support - usually it means the class was compiled in a newer version of Java than the one running the code.

So you need to find out what version of Java your Orion server supports and re-compile your classes to be compatible with that version of the JRE.
 
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That exception is thrown when you compile a class using a later Java version than the JRE that is running the class. For example, if you compile a class with a Java 5.0 compiler and then try to run it with a Java 1.4 JRE.

The -source and -target compiler flags can help you out with that.
 
Jim Buechler
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Steve and Rob,
Thanks for the advice. I know that the Orion 2.0.7 is used only up to J2EE 1.3. I tried to find earlier versions of Java EE on Sun's website, but when I clicked on the link for earlier versions, it took me to the downloads for J EE 5.

Would either of you know where to find the earlier versions of Java EE?

Alternatively, would you suggest using a different server? There is an Orion 2.0.8 which I couldn't tell what versions of Java EE it supports from there website, there is also the app server that came with Java EE 5 when I downloaded it.

Any suggestion would be much appreciated.

Thanks again guys,
Jim
 
Marshal
Posts: 80870
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Javac tool web page. Look for the -source and -target tags which Rob mentioned earlier. That might be the easiest way to start. Make sure you only use Java methods and keywords which were available in JDK1.3, so no assert or enum or boxing or for-each loops or generics.
 
Jim Buechler
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Steve and Rob,
Thanks again, I got it to work after compiling it with Rob's suggestion using -source and -target to change the compiled class to version 1.4.

Thanks again.
 
Jim Buechler
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you too, Ritchie.
 
Campbell Ritchie
Marshal
Posts: 80870
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic