How can i resolve UnsupportedClassVersionError?

207 Views Asked by At

I have installed both jdk 7 and jdk8 in my system. But my java program is compiling version in 1.8 and executing in 1.7. So it is responding UnsupportedClassVersionError. How can i overcome this problem...

4

There are 4 best solutions below

2
On

How to solve this following error.

 1) Find out due to which jar or class file this UnSupportedClassVersionError is coming?

    2) Try to compile source code of that jar with the JDK version you are using to run your program, if source is available.

    3) If you don't have source try to find the compatible version of that library.

    4) Increase the JRE version you are using to run your program.

Read more:

0
On

Run your code with jdk8 or compile it with jdk1.7.

0
On

run in jdk8 and compile with jdk 7 should be OK.Maybe compile with jdk8 and run in jdk7

0
On

Do not try to do this.

Java8 is the more recent release than Java7. So there are chances that the code which you are compiling with JDK1.8, the same code may not be executable with JDK1.7 as this may not contain the required libraries or the required functionality which are new to the JDK1.8

For Example, for-each loop, varargs, etc is supported by JDK1.5 versions and onwards. So compiling the source code containing above features and trying to run the program on JDK1.4 or it's prior versions is always going to result in an error, as those JDK versions will not be able to identify such code snippent.

However, Oracle's JVM supports backward compatibility. So you can always compile your code on previous version of JDK's and run it on the recent versions.