How to fix java.lang.unsupportedclassversionerror unsupported major.minor version 49.0 50.0 51.0 in Java

The java.lang.unsupportedclassversionerror unsupported major.minor version 50.0 error comes in Java environment when you compile your Java file in a higher Java version e.g. Java 1.6 and then trying to run the same Java program in lower Java version e.g. Java 1.5. Java is backward compatible i.e. you can run your Java 5 binary or JAR into Java or JRE 6 but vice-versa is not true. You can not run a Java program which is compiled in a higher Java version into lower JRE. class file version changes between every Java version and class file generated by javac command of Java 6 installation is not appropriate for JRE of Java 5 Installation.

In order to solve java.lang.unsupportedclassversionerror unsupported major.minor version 49.0, 50.0 or 51.0 we need to first understand What is the major and minor version of class file in Java. Every Java release has a major source version as shown in this table

Java Version    Major Version
Java 4          48.0
Java 5          49.0
java 6          50.0
java 7          51.0

So if you compile your Java source file with javac of JDK 1.6 it will create class files with major version 50.0 and if you run those class files with Java 1.5 it will throw java.lang.unsupportedclassversionerror unsupported major.minor version 50.0 error or java.lang.UnsupportedClassVersionError: Bad version number in .class file. Similarly if you compile Java program in Java 1.7 it will create class file with major version 51.0 and if you run that on lower java version you will get java.lang.unsupportedclassversionerror unsupported major.minor version 51.0

java.lang.unsupportedclassversionerror unsupported major.minor version Solution:

How to fix java.lang.unsupportedclassversionerror unsupported major.minor versionFixing java.lang.unsupportedclassversionerror unsupported major.minor version 50.0 error is easy, you just need to run with correct Java version. Always run with either same version of JDK which is use during compilation or higher version of JDK if same version is not available. Check your PATH environment variable to see if you have correct Java in your path or not. alternatively you can run java -version in your console to check which version of Java comes first in your PATH e.g.

~/java java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

That's all on What is java.lang.unsupportedclassversionerror unsupported major.minor version 49.0 or 50.0 or 51.0 and How to fix java.lang.unsupportedclassversionerror unsupported major.minor version error. Best use same version of javac and java for compiling and running your Java application.

Further Learning
Complete Java Masterclass
Java Fundamentals: The Java Language
Java In-Depth: Become a Complete Java Engineer!

Other Java debugging and troubleshooting articles


  1. Hello there, I am getting "unsupported major.minor version 51.0" Can you please help?

    1. I was also getting same error in my project, which I am trying to run it from Eclipse. It's Maven based project and I am trying to running command Run as - Maven Install. Here is the error :

      Caused by: java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0

      In my case it was compiler settings which was wrong. I was using JDK 1.6 as Java library inside Eclipse settings but my build settings for compiler was 1.7 . for example, Java source level as 1.7. Once I change eclise JRE to 1.7 version this issue got resolved.

  2. I think key here to remember that which major minor version for class files belongs to which Java release. Since 51.0 belongs to Java 7, it means class files are created by compiler shipped along with JDK 1.7. Now if you try to run those class files on any JVM other than Java 1.7, you will get that error because each of them will have lower major and minor version for class files.

  3. Hello Sir, I am getting "java.lang.UnsupportedClassVersionError: HelloWorldApp : Unsupported major.minor version 51.0" error while trying to run my first Java program from command prompt. I am using JDK 1.7 version. Can you please help to resolve this error?

  4. Had this error for maven/mvn on my mac, even though I'd installed a newer JDK. The fix appears to be:
    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home


Feel free to comment, ask questions if you have any doubt.