While running a script, I am getting the following error message in the Eclipse console:
Class has been compiled by a more recent version of the Java Environment (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0.
Java Version: 8
IDE: Eclipse Oxygen
Firefox Version: 46
This is just a version mismatch. You have compiled your code using java version 9 and your current JRE is version 8. Try upgrading your JRE to 9.
49 = Java 5
50 = Java 6
51 = Java 7
52 = Java 8
53 = Java 9
54 = Java 10
55 = Java 11
56 = Java 12
57 = Java 13
58 = Java 14
59 = Java 15
60 = Java 16
61 = Java 17
62 = Java 18
63 = Java 19
IDE: Eclipse Oxygen.3
To temporarily correct the problem do the following:
Project menu > Properties > Java Compiler > Compiler compliance level > 1.8
A permanent fix likely involves installing JDK 9.
FYI 1.8 is what Java 8 is called.
Side bar
I recently returned to Java after a foray into C# (a breath of fresh air) and installed Eclipse Oxygen onto a clean system that had never had Java installed on it before. This default everything with a brand new install of Eclipse Oxygen yet somehow or other Eclipse can't get its own parameters to match the jdk that's installed. This is the second project I created and the second time I ran into this headache. Time to go back to C#?
Related Question
has been compiled by a more recent version of the Java Runtime (class file version 53.0)
You might see this error in IntelliJ as well and this comes up in Google.
I think it's a Gradle error more than an IDE error.
The fix (stolen from here) is configure Java 11 as a Gradle JVM in IntelliJ:
File -> Settings -> Build, Execution & Development -> Build Tools -> Gradle and change Gradle JVM to 11
That screenshot stolen from the Jetbrains issue as well
You can try this way
javac --release 8 yourClass.java
For Android Studio, File -> Project Structure [Ctrl + Alt + Shift + S]
53 stands for java-9, so it means that whatever class you have has been compiled with javac-9 and you try to run it with jre-8. Either re-compile that class with javac-8 or use the jre-9
For temporary solution just right click on Project => Properties => Java compiler => over there please select compiler compliance level 1.8 => .class compatibility 1.8 => source compatibility 1.8.
Then your code will start to execute on version 1.8.
I had a similar issue from the console after building a Jar in Intellij. Using the Java configuration to update to a newer version (Windows -> Configure Java -> Update -> Update Now) didn't work and stuck at version 1.8 (Java 8).
To switch to a more recent version locally I had to install the Java 15 JDK from https://www.oracle.com/uk/java/technologies/javase-jdk15-downloads.html and add that to my Java runtime environment settings.
The solution for me was doing what Andrei Kuznetsov said at https://youtrack.jetbrains.com/issue/IDEA-251407/Failed-to-run-Android-project-in-the-Idea-20203-EAP-OutputBuildAction-has-been-compiled-by-a-more-recent-version-of-the-Java, summarized in the following image:
"Root cause: IDEA sources are now compiled against Java 11. Known workaround is to configure Java 11 as a Gradle JVM." (Andrei Kuznetsov)
Your JDK version: Java 8
Your JRE version: Java 9
Here your JRE version is different than the JDK version that's the case. Here you can compile all the java classes using JDK version 1.8. If you want to compile only one java class just change the *.java into <yourclassname>.java
javac -source 1.8 -target 1.8 *.java
source: The version that your source code requires to compile.
target: The oldest JRE version you want to support.
I'm writing this because I found the other answers hard to understand.
Essentially your JRE is not updated and/or Eclipse is not configured to use the most recent JRE.
On Windows, go to Control Panel -> Programs -> Java -> update and proceed to update java
or if you don't have Java, go to Oracle's website and download the most recent JRE.
Once this is done, go into eclipse, and under the project view, right click on your project, select Java Build Path, double click on JRE System Library, then Select Workspace Default JRE 14.1.
If a recent version of Java doesn't show up here, it probably isn't installed. Check you JRE(NOT JDK) version and make sure it's recent. If it is, try restarting the computer then trying this again.
IDE : Eclipse 2021-09
This is caused because you have compiled the code with java version 9 and have java8 installed. You don't have to update to solve this issue.
Right click on project > properties > Java Compiler > untick-Enable
project specific settings > configure workspace settings > tick-Use
default compliance settings > Apply and Close.
Now your code should be executed properly.
I've reproduced on Windows 10 the similar issue in format like:
Error: LinkageError occurred while loading main class ...
java.lang.UnsupportedClassVersionError: com/.../ServiceApplication
has been compiled by a more recent version of the Java Runtime (class file version 62.0),
this version of the Java Runtime only recognizes class file versions up to 61.0
after upgrading the project from Java 17 to Java 18.
I had project settings regarding to Java 18:
Command line:
java version "18.0.1.1" 2022-04-22
Java(TM) SE Runtime Environment (build 18.0.1.1+2-6)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)
Project Structure -> Project Settings -> Project:
Project Structure -> Project Settings -> Modules:
Project Structure -> Platform Settings -> SDKs:
And the reason of this issue was:
I forgot to specify the correct version for Run/Debug Configurations -> Build and run to Java 18 instead of Java 17:
As it was compiled with a newer Java version, but running on the older one.
If it's Maven-related issue, you can modify POM by specifying the -source and -target of the Java Compiler.
Additional helpful links:
Setting the Java Version in Maven
Consuming Jar Artifact of a Specific Java Version
Go to Project section, click on properties > then to Java compiler > check compiler compliance level is 1.8 , or there should be no yellow warning at bottom
Refreshing gradle dependencies works for me: Right click over the project -> Gradle -> Refresh Gradle Project.
You should check your Project Facets.
Project Properties > Project Facets
Change java version to the same version you are using. That work for me!
I faced this error in Intellij. Apparently, choosing java 1.8 as the project SDK doesn't affect the javac compiler that's used to build the project.
To change that, go to Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler, and change Project bytecode version to 8.
If you're using IntelliJ IDEA and having this error, try this.
Command + , (Open Preferences)
Build, Execution, Deployment > Build Tools > Gradle
Gradle JVM > Change it to a proper version
This is getting as an example
if your computer running on an older version of java and the Neo4J is compiled on the latest version, please try to install the same version or upper to your computer.
I'm getting the same problem with Sonarqube
has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Sonarqube with AzureDevOps error output:
INFO: SonarScanner 4.6.2.2472
INFO: Java 1.8.0_231 Oracle Corporation (32-bit)
INFO: Windows Server 2016 10.0 x86
INFO: User cache: C:\Windows\system32\config\systemprofile.sonar\cache
INFO: Scanner configuration file: C:\agent_a_work_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\sonar-scanner-4.6.2.2472\bin..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\agent_a_work\189.sonarqube\out\sonar-project.properties
INFO: Analyzing on SonarQube server 9.4.0
INFO: Default locale: "en_AU", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.405s
INFO: Final Memory: 3M/15M
##[error]ERROR: Error during SonarScanner execution
java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
I had Java v11 installed on the Sonarcube server, but the error is saying its the Build Agent that doesn't have Java v11.
I decided to add the Java v12 bin path to the Environment Variable Path for it to be detected. IMPORTANT THIS NEEDS TO BE DONE ON THE BUILD AGENT:
For a Hosted Build Agent you can install JDK v11 or use this PowerShell script step:
- task: PowerShell#2
displayName: 'Download and Install Java v11'
inputs:
targetType: 'inline'
script: |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$Command = "c:\jdk-11.0.15_windows-x64_bin.exe"
$Parms = "/s"
Write-Host [System.IO.File]::Exists($Command)
if ([System.IO.File]::Exists($Command)) {
Write-Host 'Downloading Java11.exe'
Invoke-WebRequest https://yourOwnUrl.com/jdk-11.0.15_windows-x64_bin.exe -OutFile $Command
}
Write-Host [System.IO.File]::Exists($Command)
& "$Command" $Prms
[System.Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Java\jdk-11.0.15")
[System.Environment]::SetEnvironmentVariable("Path", [System.Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine) + ";$($env:JAVA_HOME)\bin")
In my case, I'm building with VS2019 some C++ code that is using ANTLR4.
ANTLR4 is java based, and to use it I run java commands as a custom build step.
Earlier that day I had updated my JRE (Java Runtime Environment) on my new laptop to 1.8. Not thinking, since it's been a year since I ran ANTLR4 stuff... I need the full JDK to COMPILE with java. So I had a 1.8 RUNTIME, but the VS2019 build shell was finding the JDK1.7 compiler. Once I installed the 1.8 JDK, all was good.
So 80% of the time JRE is fine for me... it's just when I need the full JDK, DOH I need the full JDK.
In build.gradle(app) update as below: (Worked for me)
kotlinOptions {
jvmTarget = '1.8'
}
For me this problem was resolved by just installing older version of testng. Looks like It compiles with my Java 8
If you're using IntelliJ IDEA and having this error, try this.
1. Command + , (Open Preferences)
2. Build, Execution, Deployment > Build Tools > Gradle
3. Gradle JVM > Change it to a proper version
Check the version of Java configured in IDE by navigating to Settings -> Build, Execution, Deployment > Build Tools > Gradle
In my case, I use the IntellJ Idea and set JDK11 as my SDK and JDK17 in gradle setting.
Just update my SDK as JDK17, it was solved
Check the JDK in "Project Setting"(CMD+;) -> SDK
with
the gradle JVM in "Preference"(CMD+,) -> Build Tools -> gradle JVM
Faced the same issue when initialise my project from spring initizer
We need to match the version of java.sourceCompatibility and jvmTarget used for run and compile in "build.gradle.kt" file.
Last week, I updated my Mac's Android Studio from 2021.2.1 to 2021.3.1. Then our project was built failed for the similar reason:
Cause: com/android/tools/idea/gradle/run/OutputBuildAction has been
compiled by a more recent version of the Java Runtime (class file
version 55.0), this version of the Java Runtime only recognizes class
file versions up to 53.0
I found several discussion on the Jetbrains YouTrack Forum: Failed to run Android project in the Idea 2020.3 EAP (OutputBuildAction has been compiled by a more recent version of the Java Runtime (class file version 55.0)). The suggested workaround is to update the defined Gradle JDK version to JDK11, but many Android projects don't support Gradle JDK11, so does mine.
Another solution is to downgrade Android Studio from 2021.3.1 to 2021.2.1, and it worked for me. Hope it helps.
it looks like everyone is using windows for development, but if you use Linux, lower your Java version. maybe install JDK 8, the version table provided by #Nithin should give you an idea of which version you want to install.
After configuring the version of the compiler to 1.8 (your required version), try the older version of spring boot currently it is 3.0.0 by default but you can try 2.7.6 instead.
enter image description here
Related
In Visual Studio Code:
I have OpenJDK 14 correctly configured. When I try to run my project I receive the follow error:
java.lang.UnsupportedClassVersionError: (class file version 56.65535) was compiled with preview features that are unsupported. This version of the Java Runtime only recognizes preview features for class file version 58.65535
This class is a dependency and it is stored in a Nexus Repository, all this project have been compiled with JDK 12. So I try to uninstall OpenJDK 14 to install OpenJDK 12 but If I do this the project can't build because 'Preview features enabled at an invalid source release level 12, preview can be enabled only at source level 14'.
But the same project is correctly build in Eclipse for example.
Can you try running the "Java: clean the Java language server workspace" command?
Or
Updating java extension to the latest version.
As you described, the first time you try to take JRE 14 to run the file which was compiled
with javac 12, then you downgrade to JDK 12 and want to use JRE 12 to run the file. But you get the error of 'Preview features enabled at an invalid source ...'. It seems like a cache causes this. Or did you use some preview features of JDK 14 in your project?
I have solved this problem with following steps:
1 - Install JDK 12 and configure it.
2 - The project was imported from Eclipse so there are all related files in settings. One of this is "org.eclipse.jdt.core.prefs" go into it and modifie the value of "org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures" to disabled.
Seems like VSCode reads all the settings and replicate the
behavior of Eclipse IDE.
This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 6 years ago.
Pictures:
Command Prompt showing versions
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?
The issue is because of Java version mismatch. Referring to the JVM specification the following are the major versions of classfiles for use with different versions of Java. (As of now, all versions support all previous versions.)
Java SE version
Major version
1.0.2
45
1.1
45 (Not a typo, same version)
1.2
46
1.3
47
1.4
48
5.0
49
6
50
7
51
8
52
9
53
10
54
11
55
12
56
13
57
14
58
15
59
16
60
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 IDEA,
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 menu File* → Project Structure → SDKs. Make sure the JDK home path is set to 1.8.
Restart IntelliJ IDEA.
Another approach which might help is by instructing IntelliJ 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>
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 meaning you'd use javac -target 1.1.
You will need to change your compiler compliance level back to 1.7 in your IDE.
This can be done in the preferences settings of your IDE. For example, in Eclipse go to menu Windows → Preferences, select Java, and expand it. Then select Compiler and change the compliance level to 1.7. I am sure this will work from there.
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.
You need to upgrade your Java version to Java 8.
Download latest Java archive
Download latest Java SE Development Kit 8 release from its official download page or use following commands to download from the shell.
For 64 bit
# 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 32 bit
# 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 the above wget command doesn’t not work for you, watch this example video to download the Java source archive using the terminal.
Install Java with alternatives
After extracting the archive file, use the alternatives command to install it. The alternatives command is available in the 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 the 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 applications use environment variables to work. Set the Java environment variables using the 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 the /etc/environment file for auto loading on system boot.
I had the same problem... a 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, and targeting to version 1.7, fixed my problem.
If you have a problem in Android Studio and you have installed Android N, change the Android rendering version with an older one and the problem will disappear.
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.
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
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.
I solved my problem by removing old versions of JRE and installing JRE 8.
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 Edit → Installed 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.
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.
If you are using Eclipse, make sure your menu Project → Properties → Java build path → libraries → JRE system library matches your project requirements (as shown in the image).
All you need to do to solve the problem is... to make sure your version of Java is the same for both compiling and running. No matter what tools or IDEs you are using.
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.
This occurred to me when I installed a fresh Java 1.8, but left the old command line interpreter open.
It had an old path and kept on executing the application with Java 1.7 whereas project was already built with Java 1.8.
If your JDK version is right. Another reason that may cause this error is that your Android Studio is in a low version, but your Gradle version is too high. Upgrade your IDE to a newer version may help this.
Upgrade your Andorra version to JDK 1.8.
This is a version mismatch 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
You need to use JDK 1.7.0 rather than JDK 1.8.0.
To make sure it, you need to delete JDK 1.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 JDK 1.7.0, and you will succeed to generate the .jar file.
You may want to check your Run Configurations setting if you're using Eclipse v4.4 (Luna) and have already completed all steps mentioned above.
There could be several possibilities that cause this error. The root cause is a 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.
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.
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.
Just go to http://java.com/en/download/ and update your version of JRE
If you are using IntelliJ IDEA, go to Project Structure (Ctrl + Alt + Shift + S), and you can change your project's JDK.
I ran into this issue in Eclipse on Mac OS X v10.9 (Mavericks). I tried many answers on Stack Overflow ... finally, after a full day I *installed a fresh version of the Android SDK (and updated Eclipse, menu Project → Properties → Android to use the new path)*.
I had to get SDK updates, but only pulling down those updates I thought were necessary, avoiding APIs I were not working with (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.
This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 6 years ago.
Pictures:
Command Prompt showing versions
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?
The issue is because of Java version mismatch. Referring to the JVM specification the following are the major versions of classfiles for use with different versions of Java. (As of now, all versions support all previous versions.)
Java SE version
Major version
1.0.2
45
1.1
45 (Not a typo, same version)
1.2
46
1.3
47
1.4
48
5.0
49
6
50
7
51
8
52
9
53
10
54
11
55
12
56
13
57
14
58
15
59
16
60
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 IDEA,
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 menu File* → Project Structure → SDKs. Make sure the JDK home path is set to 1.8.
Restart IntelliJ IDEA.
Another approach which might help is by instructing IntelliJ 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>
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 meaning you'd use javac -target 1.1.
You will need to change your compiler compliance level back to 1.7 in your IDE.
This can be done in the preferences settings of your IDE. For example, in Eclipse go to menu Windows → Preferences, select Java, and expand it. Then select Compiler and change the compliance level to 1.7. I am sure this will work from there.
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.
You need to upgrade your Java version to Java 8.
Download latest Java archive
Download latest Java SE Development Kit 8 release from its official download page or use following commands to download from the shell.
For 64 bit
# 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 32 bit
# 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 the above wget command doesn’t not work for you, watch this example video to download the Java source archive using the terminal.
Install Java with alternatives
After extracting the archive file, use the alternatives command to install it. The alternatives command is available in the 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 the 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 applications use environment variables to work. Set the Java environment variables using the 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 the /etc/environment file for auto loading on system boot.
I had the same problem... a 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, and targeting to version 1.7, fixed my problem.
If you have a problem in Android Studio and you have installed Android N, change the Android rendering version with an older one and the problem will disappear.
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.
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
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.
I solved my problem by removing old versions of JRE and installing JRE 8.
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 Edit → Installed 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.
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.
If you are using Eclipse, make sure your menu Project → Properties → Java build path → libraries → JRE system library matches your project requirements (as shown in the image).
All you need to do to solve the problem is... to make sure your version of Java is the same for both compiling and running. No matter what tools or IDEs you are using.
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.
This occurred to me when I installed a fresh Java 1.8, but left the old command line interpreter open.
It had an old path and kept on executing the application with Java 1.7 whereas project was already built with Java 1.8.
If your JDK version is right. Another reason that may cause this error is that your Android Studio is in a low version, but your Gradle version is too high. Upgrade your IDE to a newer version may help this.
Upgrade your Andorra version to JDK 1.8.
This is a version mismatch 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
You need to use JDK 1.7.0 rather than JDK 1.8.0.
To make sure it, you need to delete JDK 1.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 JDK 1.7.0, and you will succeed to generate the .jar file.
You may want to check your Run Configurations setting if you're using Eclipse v4.4 (Luna) and have already completed all steps mentioned above.
There could be several possibilities that cause this error. The root cause is a 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.
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.
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.
Just go to http://java.com/en/download/ and update your version of JRE
If you are using IntelliJ IDEA, go to Project Structure (Ctrl + Alt + Shift + S), and you can change your project's JDK.
I ran into this issue in Eclipse on Mac OS X v10.9 (Mavericks). I tried many answers on Stack Overflow ... finally, after a full day I *installed a fresh version of the Android SDK (and updated Eclipse, menu Project → Properties → Android to use the new path)*.
I had to get SDK updates, but only pulling down those updates I thought were necessary, avoiding APIs I were not working with (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.
I am trying to install hybris, but while installing I face a problem in executing ant clean command.
I am using the latest version of java which should work.
I have also used setantenv.bat in the right path.
here is the stack trace :
Apache Ant(TM) version 1.9.1 compiled on May 15 2013
C:\work\trail\hybris\bin\platform>**ant clean**
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=128M; support
s removed in 8.0
Buildfile: C:\work\trail\hybris\bin\platform\build.xml
[echo] C:\work\trail\hybris\bin\platform/tomcat/bin
**BUILD FAILED**
C:\work\trail\hybris\bin\platform\build.xml:20: The following error occurred w
le executing this line:
C:\work\trail\hybris\bin\platform\resources\ant\antmacros.xml:73: The followin
error occurred while executing this line:
C:\work\trail\hybris\bin\platform\resources\ant\util.xml:234: -
**** **WRONG JAVA VERSION** ****
Environment check failed: You are using a not supported version of Java.
Please make sure you are using Java version 1.7 or later.
Your current Java version is: 1.8.0_40
TIP: If you are using eclipse you can configure a different JVM under
Preferences->Java->Installed JREs.
Total time: 1 second
Since you were able to get Hybris working with JDK 7, it appears that Java JDK version 1.8.0_40 does not have backwards compatibility/support for Hybris 5.2.0.6. You may want to open a bug with Hybris if you are feeling entrepid.
In eclipse go to platform - build.xml - right click on it - go to run as - external tools configuration - go to jre tab - add in separate jre the required jre version - add the build.xml file again to ant and run it
check this one
try this instead, adding java version in util.xml under platfrom folder. worked for me!
This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 6 years ago.
Pictures:
Command Prompt showing versions
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?
The issue is because of Java version mismatch. Referring to the JVM specification the following are the major versions of classfiles for use with different versions of Java. (As of now, all versions support all previous versions.)
Java SE version
Major version
1.0.2
45
1.1
45 (Not a typo, same version)
1.2
46
1.3
47
1.4
48
5.0
49
6
50
7
51
8
52
9
53
10
54
11
55
12
56
13
57
14
58
15
59
16
60
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 IDEA,
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 menu File* → Project Structure → SDKs. Make sure the JDK home path is set to 1.8.
Restart IntelliJ IDEA.
Another approach which might help is by instructing IntelliJ 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>
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 meaning you'd use javac -target 1.1.
You will need to change your compiler compliance level back to 1.7 in your IDE.
This can be done in the preferences settings of your IDE. For example, in Eclipse go to menu Windows → Preferences, select Java, and expand it. Then select Compiler and change the compliance level to 1.7. I am sure this will work from there.
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.
You need to upgrade your Java version to Java 8.
Download latest Java archive
Download latest Java SE Development Kit 8 release from its official download page or use following commands to download from the shell.
For 64 bit
# 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 32 bit
# 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 the above wget command doesn’t not work for you, watch this example video to download the Java source archive using the terminal.
Install Java with alternatives
After extracting the archive file, use the alternatives command to install it. The alternatives command is available in the 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 the 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 applications use environment variables to work. Set the Java environment variables using the 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 the /etc/environment file for auto loading on system boot.
I had the same problem... a 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, and targeting to version 1.7, fixed my problem.
If you have a problem in Android Studio and you have installed Android N, change the Android rendering version with an older one and the problem will disappear.
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.
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
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.
I solved my problem by removing old versions of JRE and installing JRE 8.
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 Edit → Installed 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.
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.
If you are using Eclipse, make sure your menu Project → Properties → Java build path → libraries → JRE system library matches your project requirements (as shown in the image).
All you need to do to solve the problem is... to make sure your version of Java is the same for both compiling and running. No matter what tools or IDEs you are using.
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.
This occurred to me when I installed a fresh Java 1.8, but left the old command line interpreter open.
It had an old path and kept on executing the application with Java 1.7 whereas project was already built with Java 1.8.
If your JDK version is right. Another reason that may cause this error is that your Android Studio is in a low version, but your Gradle version is too high. Upgrade your IDE to a newer version may help this.
Upgrade your Andorra version to JDK 1.8.
This is a version mismatch 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
You need to use JDK 1.7.0 rather than JDK 1.8.0.
To make sure it, you need to delete JDK 1.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 JDK 1.7.0, and you will succeed to generate the .jar file.
You may want to check your Run Configurations setting if you're using Eclipse v4.4 (Luna) and have already completed all steps mentioned above.
There could be several possibilities that cause this error. The root cause is a 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.
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.
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.
Just go to http://java.com/en/download/ and update your version of JRE
If you are using IntelliJ IDEA, go to Project Structure (Ctrl + Alt + Shift + S), and you can change your project's JDK.
I ran into this issue in Eclipse on Mac OS X v10.9 (Mavericks). I tried many answers on Stack Overflow ... finally, after a full day I *installed a fresh version of the Android SDK (and updated Eclipse, menu Project → Properties → Android to use the new path)*.
I had to get SDK updates, but only pulling down those updates I thought were necessary, avoiding APIs I were not working with (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.