java.lang.UnsupportedClassVersionError: Bad version number in .class file? (Eclipse)

Before hitting the solution let's get to know why this error occurs in java.So when JVM tries to load a class   and found that class version is not supported it throws UnSupportedClassVersionError  and it generally occurs if a higher JDK version is used to compile the source file and a lower JDK version is used to run the program.
For example: if you have written your program using Java 1.6 and compiled also and now you run that program in 1.5 you will get the error  "java.lang.UnsupportedClassVersionError: Bad version number in .class file [at java.lang.ClassLoader.defineClass1(Native Method)]".

So now we come to how to resolve this issue in Eclipse. Right click on the project in Eclipse and click on Properties menu.After that click on Java Compiler menu. In right hand side uncheck use compliance check box and from the drop-down menu click the version you need .For me i have to select 1.6.After that click ok and clean your project.If again problem comes then once restart your eclipse.
Hope this solution will work for you.


Comments

Popular posts from this blog

Arrays.sort() and Collections.sort() NullPointerException

org.xml.sax. SAXParseException: Element type "web-app" must be declared.

Sentimental Analysis : PART 1