• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reg : java.lang.UnsupportedClassVersionError  RSS feed

 
Vaideeswaran Natarajan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I checked out a new project from CVS and was able to build it without any compilation errors. When I try to run the application is throws an exception.

Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class []: Constructor threw exception; nested exception is java.lang.UnsupportedClassVersionError: Bad version number in .class file

I checked the JRE settings on my eclipse and it uses the correct version. Can anyone please give your valuable suggestion/advice to my issue.

Thank you in advance.

Thanks
V
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That error message means that you are trying to run a class file that was compiled on a newer version of the JDK on an older version of the JRE. For example, you cannot run classes compiled for Java 5 on Java 1.4 - you'll get an UnsupportedClassVersionError if you try that.

Which version(s) of Java are you using, and are you sure that all the classes you are using are compiled for the Java version that you're running the program on?

I recommend to always use the JDK that your system needs to run on - for example, if your production system uses Java 5, use JDK 5 (don't try to use JDK 6 and setting output to Java 5 compatible, because that will not catch the usage of classes in the standard API that only exist in Java 6).
 
Vaideeswaran Natarajan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jesper.

I am sure the code is getting compiled with jdk1.5 and executed with jre1.5. I am using eclipse and when I right click the preferences it shows me that it uses jre 1.5. I am also using other jars will that give any issues.

Is there any other way to fix this issue using eclipse.

Adding to this I am working on couple of other projects in the same workspace but others seem to work with no issues. This puts me into more trouble.


Thank you for your help.

Thanks
V
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vaideeswaran Natarajan wrote:I am also using other jars will that give any issues.

And are all those JAR files compiled for Java 5.0 or before?

Is there any other way to fix this issue using eclipse.

The issue is completely unrelated to Eclipse.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All library dependencies must also satisfy the JRE version requirements. Check your path--*something* you're trying to run is compiled with a version of Java higher than the one you're trying to run it with.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!