[Solved-4 Solutions] Unsupported major.minor version 52.0



Error Description:

import java.applet.Applet;
import java.awt.*;

public class Hello extends Applet {

    // Java applet to draw "Hello World"
    public void paint (Graphics page) {
        page.drawString ("Hello World!", 50, 50);
    }
}
click below button to copy the code. By - Java tutorial - team

Hello.java

import java.applet.Applet;
import java.awt.*;

public class Hello extends Applet {

    // Java applet to draw "Hello World"
    public void paint (Graphics page) {
        page.drawString ("Hello World!", 50, 50);
    }
}
click below button to copy the code. By - Java tutorial - team

Hello.html

<HTML>
    <HEAD>
        <TITLE>HelloWorld Applet</TITLE>
    </HEAD>

    <BODY>
        <APPLET CODE="Hello.class" WIDTH=300 HEIGHT=150>
        </APPLET>
    </BODY>
</HTML>
click below button to copy the code. By - Java tutorial - team

Error

Hello : Unsupported major.minor version 52.0

unsupported

Learn java - java tutorial - unsupported - java examples - java programs

Solution 1:

  • The issue is because of Java version mismatch.
    • J2SE 9 = 53
    • J2SE 8 = 52
    • J2SE 7 = 51
    • J2SE 6.0 = 50
    • J2SE 5.0 = 49
    • JDK 1.4 = 48
    • JDK 1.3 = 47
    • JDK 1.2 = 46
    • JDK 1.1 = 45
  • These are the assigned major numbers. The error regarding the unsupported major.minor version is because during compile time you are using a higher JDK and a lower JDK during runtime. Thus, the 'major.minor version 52.0' error is possibly because the jar was compiled in jdk 1.8, but you are trying to run it using a jdk 1.7 environment. The reported number is the required number, not the number you are using. To solve this, it's always better to have the jdk and jre pointed to the same version. In Intellij,
    • Go to Maven Settings -> Maven -> Importing. Set the JDK for importer to 1.8
    • Go to Maven Settings -> Maven -> Runner. Set the JRE to 1.8
    • Go to File -> Project Structure -> SDKs. Make sure the JDK home path is set to 1.8
<key>JVMVersion</key>
<string>1.8*</string>

click below button to copy the code. By - Java tutorial - team

Solution 2:

  • The smart way to fix that problem is to compile using the latest SDK and use the cross compilation options when compiling. To use the options completely correctly requires the rt.jar of a JRE (not JDK) of the target version.
  • Given the nature of that applet, it looks like it could be compiled for use with Java 1.1.

Solution 3:

  • You will need to change your compiler compliance level back to 1.7 in your IDE. This can be done in the prefences settings of your IDE for example in Eclipse go to Windows ---> Prefences then select Java and expand it then select Compiler and change the compliance level to 1.7.

Solution 4:

  • You must run and compile your application with the same version of Java. If you're using Eclipse you should do 2 things:
    • In Eclipse, click on "Window > Preferences", and in the window that appears, on the left side, under "Java", click on "Installed JREs", click on "Add..." and navigate to the folder that contains the JDK.
    • Right-click on your project and click on "Properties", in the window that appears, on the left side, click on "Java Compiler" and uncheck "Use compliance from execution environment on the Java Build Path", this allows you to choose in the the list "Compiler compilance level" the same version that you set in the previous step.

Related Searches to Unsupported major.minor version 52.0