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.
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).
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.
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.