How to fix java lang UnsupportedClassVersionError Unsupported major minor version

+1 vote

I have JRE installed, and I have setup my path variable to the .../bin directory.

When I run my "Hello world" in Notepad++, I get this message:

java.lang.UnsupportedClassVersionError: test_hello_world :
 Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
       .........................................

I think the problem here is about versions; some version of Java may be old or too new.

  1. How do I fix it?
  2. Should I install the JDK, and setup my path variable to the JDK instead of JRE?
  3. What is the difference between the PATH variable in JRE or JDK?
Jun 8, 2018 in Java by developer_1
• 3,320 points
2,903 views

1 answer to this question.

0 votes

This error means you're trying to load a Java "class" file that was compiled with a newer version of Java than you have installed.

For example, your .class file could have been compiled for JDK 7, and you're trying to run it with JDK 6.

So the solution is to either:

  • Upgrade your Java runtime or
  • Recompile the class if you have the source, using your local Java compiler (if you have one).

    javac FileName.java

For developers, this can happen if another developer checks in a .class file, and they've got a newer version of java than you have!

answered Jun 8, 2018 by Rishabh
• 3,620 points

Related Questions In Java

0 votes
1 answer
+1 vote
1 answer

How to tell the Maven to use the latest version of dependency in Java?

If you always want to use the ...READ MORE

answered Jun 26, 2018 in Java by Sushmita
• 6,910 points
14,648 views
0 votes
1 answer

How to prevent java.lang.NumberFormatException in Java?

"N/A" is not integer. It must throw NumberFormatException if you ...READ MORE

answered Jun 26, 2018 in Java by sharth
• 3,370 points
4,453 views
0 votes
1 answer

Unsupported major.minor version 52.0

The issue is because of a Java ...READ MORE

answered Dec 30, 2020 in Java by Gitika
• 65,910 points
6,072 views
+1 vote
2 answers

Is there a code to find 64-bit JVM or 32-bit JVM (from within a program)?

Do I need to understand the difference ...READ MORE

answered Jun 11, 2019 in Java by Jim
• 810 points
2,012 views
0 votes
1 answer

Getting "Unsupported major.minor version" error.

I will recommend not to upgrade the ...READ MORE

answered Feb 22, 2019 in Java by Sapan
1,342 views
0 votes
1 answer

Error:java.lang.UnsupportedClassVersionError: Unsupported major.minor version

Hello @kartik, This error means you're trying to ...READ MORE

answered Jul 28, 2020 in Java by Niroj
• 82,880 points
1,362 views
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 79,202 views
0 votes
3 answers

How to parse JSON in Java

import org.json.*; JSONObject obj = new JSONObject(" .... ...READ MORE

answered Aug 20, 2018 in Java by Daisy
• 8,120 points
3,678 views
0 votes
1 answer

How to pad string in Java?

Padding to 10 characters: String.format("%10s", "foo").replace(' ', '*'); String.format("%-10s", ...READ MORE

answered May 1, 2018 in Java by Rishabh
• 3,620 points
783 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP