java.lang.UnsupportedClassVersionError: Bad version number in .class file
If you hit this kind of error than its time to realize that Java byte code might differ between JDK versions :-) You'll find a long list of explanations about the Java Class file format all over in the web (http://en.wikipedia.org/wiki/Class_%28file_format%29).
Here is a list of class file versions and the corresponding JDK
J2SE 6.0 = 50 (0x32 hex),
J2SE 5.0 = 49 (0x31 hex),
JDK 1.4 = 48 (0x30 hex),
JDK 1.3 = 47 (0x2F hex),
JDK 1.2 = 46 (0x2E hex),
JDK 1.1 = 45 (0x2D hex).
J2SE 5.0 = 49 (0x31 hex),
JDK 1.4 = 48 (0x30 hex),
JDK 1.3 = 47 (0x2F hex),
JDK 1.2 = 46 (0x2E hex),
JDK 1.1 = 45 (0x2D hex).
Ok thanks for the list but how do I get the version out of an existing class file?
Answer:
javap -v MyClass | more
this will print out something like this:
class MyClass extends java.lang.Object
minor version: 0
major version: 50
....
minor version: 0
major version: 50
Keine Kommentare:
Kommentar veröffentlichen