Sunday, October 25, 2009

UnsupportedClassVersionError in Java

Most of you would have come across an error like: java.lang.UnsupportedClassVersionError: Bad version number in .class file
[at java.lang.ClassLoader.defineClass1(Native Method)]

on running a compiled java class file.

This error comes when you compile the java file against one version of jdk and run it on an earlier version of jvm. In essence you can not run .class files that are compiled with a newer version than the JVM.

No comments: