0

I am looking for clarification in jdk versions.

I am getting error

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

I hope this error is for different jdk version. I am having myeclipse6.0.1 and weblogic10.3.

Now, in my systems has jdk1.5 but weblogic has jdk1.6, as well myeclipse supporting 1.5 only.

I read the all forums and they said compile is different version and running different version.

So, here i thought program compliling 1.5 and running 1.6.

Is it correct ?

skaffman
405k96 gold badges825 silver badges775 bronze badges
asked Jan 31, 2011 at 17:16
1
  • this error getting when running the project.it was deploying successfully. Commented Jan 31, 2011 at 17:22

1 Answer 1

2

This means that the Java program was compiled for a newer version of Java than you are trying to run it with.

The easiest way to be certain is to use the same version of Java for compiling and building as is to be used on the final system. For you, this is most likely Java 5.

answered Jan 31, 2011 at 17:32
Sign up to request clarification or add additional context in comments.

4 Comments

Apparently it's possible to get a Java 6 compiler to generate bytecode for Java 5, but I could never get it to work properly. It ended up being easier just to get a Java 5 compiler.
It certainly is possible. But for it to work reliably(1), you need to use the -bootclasspath option of javac, which requires an rt.jar (not a JDK) of the target version. (1) As well as specifying -source/-target.
@britishmutt, it is possible, but even with byte codes being correct, you are still compiling against a newer version of the runtime library, and subtle differences exist. For Hudson we use the Eclipse compiler with ant running under the appropriate JRE.
@AT, TRA: Yep, that's what I was meaning. It's a bit of rabbit hole to get cross-compilation working correctly.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.