This question already has an answer here:

Pictures:

Command Prompt showing versions Command Prompt showing versions

Picture of error Picture of error

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);
    }
}

Hello.html

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

    <BODY>
        <APPLET CODE="Hello.class" WIDTH=300 HEIGHT=150>
        </APPLET>
    </BODY>
</HTML>

Error

Hello : Unsupported major.minor version 52.0

What may the problem be?

share|improve this question

marked as duplicate by ManoDestra, Ebbe M. Pedersen, Simon MᶜKenzie, ldg, George Garchagudashvili Jul 20 '16 at 6:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

111  
Java version mismatch. Execute using JRE 8. – devnull Mar 18 '14 at 19:42
    
Can you please tell me what I can do? Looking at the versions provided through Command Prompt, they both seem to be 1.8.0, unless I'm completely wrong. – user3397452 Mar 18 '14 at 19:44
1  
Check your browser plugin instead. – devnull Mar 18 '14 at 19:47
1  
Well that shows you've got Java 8 installed... it tells us nothing about what you're using to run the applet in your browser. – Jon Skeet Mar 18 '14 at 19:47
1  
Just need to double check your system environment variable JDK_HOME and JRE_HOME point to JAVA 1.8 as well. – Luke Sep 17 '15 at 5:48

26 Answers 26

The issue is because of Java version mismatch. Referring to the Wikipedia Java Class Reference :

  • 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,

  1. Go to Maven Settings -> Maven -> Importing. Set the JDK for importer to 1.8
  2. Go to Maven Settings -> Maven -> Runner. Set the JRE to 1.8
  3. Go to File -> Project Structure -> SDKs. Make sure the JDK home path is set to 1.8

Restart Intellij

Another approach which might help is by instructing IDEA which JDK version to start up with.

Go to : /Applications/IntelliJ\ IDEA\ 15\ CE.app/Contents/Info.plist and replace the JVM version with :

<key>JVMVersion</key>
<string>1.8*</string>
share|improve this answer
    
"J2SE" was only used till Java 1.5 and is nowadays called "Java SE", see en.wikipedia.org/wiki/Java_Platform,_Standard_Edition – Tim Büthe Sep 6 '16 at 14:38
    
The best answer!! Oddness: I have my alternatives set to JRE 7, and build tools with JDK8. At runtime it says 'verion 52.0' unsupported. This probably means the compile target was set to java 8. Maven and I need to have words. – Kieveli Sep 7 '16 at 16:26
1  
I have javaHome=/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/‌​Contents/Home, and still getting this error. – Igor Ganapolsky Dec 1 '16 at 18:22
1  
How to fix this from Intellij IDEA in case I need to use 1.7? Everything works fine from command line – Yuriy Yunikov Apr 18 at 16:13
    
@YuriyYunikov I have the same problem now. Please tell me if you found a way out. – riroo Jun 13 at 15:14

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.

share|improve this answer

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. Am sure this will work from there

share|improve this answer

You must run and compile your application with the same version of Java.

If you're using Eclipse you should do 2 things:

  1. 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.

  2. 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.

share|improve this answer
2  
+1 for the 2nd step which is important, and which can also be done globally (not just project-specific) in Window > Preferences > Java > Compiler, where you need to set "Compiler compliance level" to the appropriate version. – Sk8erPeter Apr 5 '16 at 16:24
    
Note that when doing step 1 here, you may or may not want to change the default JRE verse just setting it for the project. – BuvinJ Nov 2 '16 at 17:29

I had the same problem... an JDK and Plug -In version conflict.

I compiled using 1.8 ... the latest one, and that message started to appear. So i've searched for the JRE 7 (http://www.oracle.com/technetwork/java/javase/downloads/server-jre7-downloads-1931105.html).. and installed it... again... Now 1.8 and 1.7 in the same computer.

Using Netbeans , and compiling, targeting to version 1.7, fixed my problem.

share|improve this answer
    
You can use 1.8 to to compile for 1.7. – m0skit0 Jul 21 '15 at 12:11

You need to upgrade your java version to java 8.

Downloading Latest Java Archive

Download latest Java SE Development Kit 8 release from its official download page or use following commands to download from shell.

For 64Bit

 # cd /opt/

 # wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.tar.gz"

 # tar xzf jdk-8u51-linux-x64.tar.gz

For 32Bit

 # cd /opt/

 # wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-i586.tar.gz"

  # tar xzf jdk-8u51-linux-i586.tar.gz

Note: If Above wget command doesn’t not work for you watch this example video to download java source archive using terminal.

Install Java with Alternatives

After extracting archive file use alternatives command to install it. alternatives command is available in chkconfig package.

 # cd /opt/jdk1.8.0_51/

 # alternatives --install /usr/bin/java java /opt/jdk1.8.0_51/bin/java 2

 # alternatives --config java

At this point JAVA 8 has been successfully installed on your system. We also recommend to setup javac and jar commands path using alternatives

 # alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_51/bin/jar 2

 # alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_51/bin/javac 2

 # alternatives --set jar /opt/jdk1.8.0_51/bin/jar

 # alternatives --set javac /opt/jdk1.8.0_51/bin/javac 

Check Installed Java Version

Check the installed version of java using following command.

root@tecadmin ~# java -version

java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

Configuring Environment Variables

Most of java based application’s uses environment variables to work. Set the Java environment variables using following commands

Setup JAVA_HOME Variable

 # export JAVA_HOME=/opt/jdk1.8.0_51
Setup JRE_HOME Variable

 # export JRE_HOME=$JAVA_HOME/jre
Setup PATH Variable

 # export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

Note that the change to the PATH variable put the new Java bin folders first so that they override any existing java/bins in the path. It is a bit sloppy to leave two java/bin folders in your path so you should be advised to clean those up as a separate task.

Also put all above environment variables in /etc/environment file for auto loading on system boot.

share|improve this answer

If you have problem in Android Studio and you have installed Android N, change Android rendering version with older one and the problem will disappear.

enter image description here

share|improve this answer
    
I got when using Build Tools 24.0.0-rcX with API 23. Should be using 23.0.2 – hnilsen Mar 23 '16 at 13:41

If you're using the NetBeans IDE, right click on the project and choose Properties and go to sources, and you can change the Source/Binary Format to a lower JDK version.

Enter image description here

share|improve this answer
1  
C:\Program Files\netbeans\etc\netbeans.conf contains a netbeans_jdkhome – Wouter Jun 14 '16 at 14:50

Unsupported major.minor version 52.0 comes when you are trying to run a class compiled using Java 1.8 compiler into a lower JRE version e.g. JRE 1.7 or JRE 1.6. Simplest way to fix this error is install the latest Java release i.e. Java 8 and run your program.

Read more: http://javarevisited.blogspot.com/2015/05/fixing-unsupported-majorminor-version.html#ixzz4AVD4Evgv

share|improve this answer

It happens when you compile your projects on higher version of java(say jdk 1.8) and then run it on a lower version (say jdk 1.7).

If you have JRE-1.7 library in your project path then ,

1.Right click on project

2.Go to Properties

3.Select Project Facets

4.Find Java in rows and then choose version (say 1.7) if using JRE-1.7

5.Click Apply and run your project.

share|improve this answer

I could solve the same problem using the below solution.

In my project, I added a JAR file which were created in Java 8. And my project was referring to JRE 7. When I changed project JRE to 8, my problem was solved.

Steps:

In Eclipse, right click on the project name in project explorer → Build path → Libraries → click on JRE version → click EditInstalled JRE → Add → Standerd VM → select JRE home click-path (path should be localePath\java\jdk1.8.0_25\jre) → provide name → Save → select same JRE for project → Finish → OK. Refresh/build project once → try to run your Java file. It should work.

share|improve this answer

I had Java 1.7 & 1.8 installed (with SBT 2.4 that requires Java 1.8). Even though my project was linked to Java 1.8, I had to change the JAVA_HOME environment variable to point 1.8. Finally, problem solved.

share|improve this answer

If you are using eclipse, make sure your Project->properties->java build path->libraries->JRE system library matches to your project requirements. (As shown in the image) enter image description here

share|improve this answer

all you need to do to solve the problem is... to make sure your version of java is same for both compile and running. no matter what tools or ide you are using.

share|improve this answer
    
How can you check? – SaiyanGirl Jul 21 '16 at 21:20
    
what tools you are using for compile and running your project – Nixit Patel Jul 25 '16 at 17:01
1  
I am using eclipse. and i get same error. I am using java 1.7.80. I have checked everywhere, the version is same. Java 8 is not even installed on my pc. – Pallavi Jul 26 '16 at 6:29

I solved mine by removing old versions of JRE and installed JRE 8

share|improve this answer

This occurred to me when I installed fresh Java 1.8 but left old command line interpreter open. It had old path and kept on executing the app with Java 1.7 whereas project was already built with Java 1.8.

share|improve this answer

If you are using Linux and you have different versions of Java installed, use the following command:

sudo update-alternatives --config java

This will give a quick way of switching between the Java versions installed on the system. By choosing Java 8 i will solve your problem

share|improve this answer

If your JDK version are right. Another reason may cause this error is that your Android Studio is in a low version but your gradle version are too high. Upgrade your IDE to a newer version may help this.

share|improve this answer
    
Such a basic idea but sometimes it's easy to get tunnel vision when you're focussing on a specific error that you don't even think to check your IDE version. Note: I was way behind and at no point did Android Studio urge me to update (1.5 > 2.3). I suspect I had suppressed upgrade warnings at some point. – Jacksonkr Mar 14 at 14:01

You need to use jdk1.7.0 rather than jdk1.8.0.

To make sure it, you need to delete jdk1.8.0 on your computer.

If you use mac, you need to delete:

/Library/Java/JavaVirtualMachines/jdk.jdk

/Library/PreferencePanes/JavaControlPanel.prefPane

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin

Then, you need to reinstall jdk1.7.0, and you will succeed to generate the .jar file.

share|improve this answer

Upgrade your Andorra version to JDK 1.8 This is a version miss match that your compiler is looking for java version 8 and you have java version 7. You can run an app build in version 7 in version 8, but you can't do vice versa because when it comes to higher levels ,versions are embedded with more features, enhancements rather than previous versions Download JDK version from this link

And set your JDK path for this

share|improve this answer

You may want to check your Run Configurations setting if you're using Eclipse Luna and already completed all steps mentioned above.

There could be several possibilities that cause this error. The root cause is mismatch of the project require compilation in JDK1.8/JRE8 while the environment compiler is JDK1.7/JRE7.

You can check my blog post to go through all your settings are correct.

share|improve this answer
1  
you've linked to what looks like a great answer, but at stack overflow we need the details not just a link to make the answer here great. – Martin Serrano Apr 15 '15 at 4:28

None of these answers helped me, but I found a solution.
I had a webproject used in Wildfly 8.2, built with Maven, source and target was set to 1.8 on maven-compiler-plugin, as well as all Eclipse and Maven settings were set to Java 1.8. The problem was that Wildfly 8.2 cannot handle Java 1.8, so I had to set everything to 1.7 and it worked.

share|improve this answer

If you are using Intellij go to Project Structure (Ctrl+Alt+Shift+S), and you can change the your projects JDK.

share|improve this answer

Just want to add this. I had this problem today. Adjusted the settings in my project, rebuilt, and same problem. I had (incorrectly) assumed that changing the settings in my project (Eclipse) would cause the projects on which my project depends to be recompiled also. Adjusting the settings to all of the projects up the dependency tree solved the problem.

share|improve this answer

I ran into this issue in Eclipse on Mac OS X Mavericks. I tried many answers on SO .. finally, after a full day I installed a fresh version of the Android SDK (and updated Eclipse Project->Properties->Android to use the new path). I had to get SDK updates, but only pulling down only those updates I thought were necessary, avoiding API I was not working with those APIs (like like Wear and TV) .. and that did the trick. Apparently, it seems I had corrupted my SDK somewhere along the way.

btw .. I did see the error re-surface with one project in my workspace, but it seemed related to an import of appcompat-7, which I was not using. After rm-ing that project, so far haven't seen the issue resurface.

share|improve this answer

Just go to http://java.com/en/download/ and update your version of JRE

share|improve this answer

protected by Community Jun 21 '15 at 23:31

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.