At times we see this runtime Exception
in the logs or on console that causes the JVM abort itself or causes the request to fail.<!>
java.lang.UnsupportedClassVersionError: SocketDriver (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.security.AccessController.doPrivileged(Native Method)
Reason for this Exception
UnsupportedClassVersionError which subclasses java.lang.ClassFormatError which in turn subclasses java.lang.LinkageError (which is a direct subclass of java.lang.Error). This error is thrown when the JVM (Java Virtual Machine) attempts to loads a class file and finds that the major and minor version numbers of that class file are not supported. This normally happens when a higher version of Java Compiler is used to generate the class file (bytecodes) than the JVM version which is used to load & execute that class file. However the reverse scenario is fine, i.e if you run a Java Class that is compiled in a lower version of Java Compiler and run in higher version of JVM.
JVM Class Format Versions
The class file format version is represent by minor (Mi) and major version(Mj) numbers. It’s is stored with the compiled class itself. So a class will be said to a version(v) as
v = Mj.Mi
As per Java VM Spec, “A Java virtual machine implementation can support a class file format of version v if and only if v lies in some contiguous range Mi.0 v Mj.m. Only Sun can specify what range of versions a Java virtual machine implementation conforming to a certain release level of the Java platform may support.” For example: Implementations of version 1.2 of the Java 2 platform can support class file formats of versions in the range 45.0 through 46.0 inclusive.
Major version number of the class file formats of the popular Java versions are: J2SE 6.0 = 50, J2SE 5.0 = 49, JDK 1.4 = 48, JDK 1.3 = 47, JDK 1.2 = 46, JDK 1.1 = 45.
So in that sense a class compiled in Java 1.5 would not run against a 1.4 JVM , but the reverse, a 1.4 compiled class will run under 1.5 Compiler with no issues.
In order to resolve it, make sure you are not running the lower version of JVM by mistake, so check your Java Home Environment Variable or your start-up script, but if your JVM version is right, try to find details about the Class, what jar file it belongs to etc. If its a 3rd party library , try to find the same jar file compiled under a lower version of JDK. If its a custom jar, compile that library with the lower version of JVM and try again.[pb_builder]