java.lang.UnsupportedClassVersionError happens when you’re trying to load a Java “class” file that was compiled with a newer version of Java and you are trying to load(run) it with an older version.
In other words, it could mean that Your system is running a lower Java version than the one used to compile your code and vice versa
For example, your code was written in Java7 however maybe it was done using Java7update25 and your system is running Java7update24. Thus they both are effectively the same major version but the minor version do differ.
51.0 means that you are using java version 7, others may be as follows:
- Java 8 => 52
- Java 7 => 51
- Java 6.0 => 50
- Java 5.0 => 49
- JDK 1.4 => 48
- JDK 1.3 => 47
- JDK 1.2 => 46
- JDK 1.1 => 45
To fix the actual problem you should uninstall all JVM runtimes including JDK and download the latest and re-install. That should fix any Unsupported major.minor error as you will have the latest JRE and JDK (Maybe newer than the one used to compile your code)
OR
specify the target parameter to the Java compiler to instruct the compiler to create code compatible with the specified Java versions.
For example, in order to generate class files compatible with Java 1.6, use the following command line:
javac -target 1.6 HelloWorld.java