I'm trying to deploy an EAR file to WebLogic Server Version: 12.1.1.0 but it gives me this error:
weblogic.management.DeploymentException:
Error mydirectory/weblogic/LifeCycleListener : unsupported classversion 52.0
LifeCycleListener is a .java file. Here is the Java version I have installed on my machine, and with which i compiled the EAR file:
C:\Users\USER>java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) Client VM (build 25.11-b03, mixed mode, sharing)
javac 1.8.0_11
why is this happening? i have the JDK up to date and everything..is there any code I can put in the java file or any solution?
You compiled your code with Java 8, but your Weblogic server is running an older Java version.
Either compile your code using the Java version of your target server, or upgrade your server's Java engine to Java 8.
Related
I have recently been writing some Java programs on my Windows computer. I have been trying to use java -jar to run compiled jars in order to see errors more clearly, but when I try to do this, I get the following error:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/company/app/GUI has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 52.0
This obviously means that my java version is outdated. However, when I took a look at the Java Updater, it shows that I am running the latest version.
Running java -version shows this:
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) Client VM (build 25.261-b12, mixed mode)
So why is Command Prompt using an older version, and how do I change it?
Thank you for your help.
This error clearly indicates that you try to run a .jar file built with JDK 13 (major version 57) on a JRE/JDK 8 (major version 52) which is provided in PATH setting and thus invoked when running java -jar / java -version commands.
If you have JDK 13 installed on your machine, you need to check environment variable PATH and/or JAVA_HOME:
C:\Users\hp1>echo %JAVA_HOME%
C:\Java\jdk-13.0.2
C:\Users\hp1>echo %PATH%
C:\Windows\system32;C:\Java\jdk-13.0.2\bin
C:\Users\hp1>java -version
openjdk version "13.0.2" 2020-01-14
OpenJDK Runtime Environment (build 13.0.2+8)
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)
If PATH refers JRE/JDK 8, you may create another variable and update PATH (copy non-java paths):
>set JAVA_13=**path_to_your_jdk_13**
>set PATH=C:\Windows\system32;%JAVA_13%\bin
If you do not have JDK 13 on your machine, to resolve this issue you should rebuild the .jar file to make it compatible with JDK 8 providing that the code is not using any features from the newer versions.
I'm doing this project where I have a webservice done in Java (HttpServlet) that uses Hibernate to select, insert and update information into a database and return an array of objects as JSON to whoever connects to the JSON endpoint.
I created it on my local computer and it works fine. However, I'm now trying to see how it would work on an actual server instead of locally.
So I connected through SSH to the server and copied the .war build to the Tomcat webapps folder, tried to run it, then I got the below error:
javax.servlet.ServletException: Servlet execution threw an exception
root cause java.lang.UnsupportedClassVersionError: org/hibernate/HibernateException : Unsupported major.minor version 52.0 (unable to load class org.hibernate.HibernateException)
So naturally I looked on StackOverflow to see what this error is about and I found that it's when you create your project in one version of Java and try to run the project on an inferior java machine. And I did that, indeed.
I created my project using Java 8 and I was running it on Java 7, on the server. So I updated the server to use Java 8. However, after updating to Java 8, I still get the same error.
If I run the java -version command, here's what I get:
LOCAL COMPUTER:
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
SERVER:
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
As you can see, I have java 1.8.0_121 on my local machine and java 1.8.0._111 on the server. Do you think there's any chance that that is the problem? Aren't they both Java 8?
Also, how does Tomcat know which java to use? I have 3 versions on the server (2 versions of the Java 7 and one version of the Java 8, java 1.8.0_111). How does Tomcat know which one to use?
To choose which one to use I used the sudo update-alternatives --config java command and chose the 1.8.0_111 version from there (the server is Ubuntu 12.04).
The problem is - I keep getting that error: java.lang.UnsupportedClassVersionError: org/hibernate/HibernateException : Unsupported major.minor version 52.0 (unable to load class org.hibernate.HibernateException) - and I can't run my project on the server.
Any suggestions?
When I got this error few days back, I had different versions of JDK and JRE running on my machine. I rectified it by setting the correct JRE path in Project's Build Path and also in the Window Preferences->Java->Installed JRE's. Also if you go to setenv.bat in your Tomcat\bin, there you specify which version of java should the Tomcat use by specifiying this:
set "JRE_HOME=%ProgramFiles%\Java\jre1.8.0_121", (obv, your version might be different so change that accordingly).
I hope that answers your query!
Edit: If you are wondering what setenv.bat is, refer: https://docs.oracle.com/cd/E40518_01/integrator.311/integrator_install/src/cli_ldi_server_config.html it explains what this bat file should contain.
As per the Documentation,
Hibernate 5.2 and later versions require at least Java 1.8 and JDBC 4.2.
Hibernate 5.1 and older versions require at least Java 1.6 and JDBC 4.0.
When building Hibernate 5.1 or older from sources, you need Java 1.7 due to a bug in the JDK 1.6 compiler.
I have a simple Java application but when I run it on Eclipse, the following error will be shown in console.
/Eter/Jack/Java - Installation/jre1.7.0/bin/java: /Eter/Jack/Java - Installation/jre1.7.0/bin/java: cannot execute binary file
Running this command "java -version" in terminal shows following
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
I had a look at the jre1.7.0 to find out it has .exe files. I removed the folder and it showed a new error as following.
Unsupported major.minor version 51.0
Using this answer I changed the version of my Java on Eclipse and that solved the problem.
This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 8 years ago.
I am currently trying to run a plugin im working on onto a test server. The Minecraft server is running spigot 1.7.10, here is the servers java version:
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
here is my java version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
So it makes no sense why I should be getting this error on my plugin when loading it.
26.11 02:19:38 [Server] INFO org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: mad/madster/msm/Main : Unsupported major.minor version 52.0
I am using eclipse luna on windows 8.
You are compiling your plugin with the Java 8 compiler. You are running your server with Java 7, which is not capable of reading the Java 8-format class files in your plugin.
You can either:
Update the server to Java 8.
Make Eclipse use the Java 7 compiler (if it's installed on your development machine) by selecting a Java 7 JDK version, in Preferences > Java > Installed JREs:
Make Eclipse tell the Java 8 compiler to pretend to be the Java 7 compiler, by setting your "compiler compliance level" to 1.7, in Preferences > Java > Compiler:
You have to download java8 and run it with this jre.
Your code has been compiled with Java 8, while you are trying to run it with Java 7.
Note that Eclipse has it's own compiler and does not use the one from the JDK and most probably
it is configured to use Java 8. Check you eclipse compiler preferences.
I'm using Tomcat 7.0.26 in my ubuntu server, I've installed Oracle JDK and here is the output of
java -version command
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
And output of javac -version command is :
javac 1.7.0_51
I didn't specify JAVA_HOME and JRE_HOME manually and I've installed JDK from ppa:webupd8team repository.
And in my windows machine I export my web project to war file with Eclipse and compiler version of it is 1.7, I checked it in Properties of my project, in Java Compiler section, configuration is below :
Use compliance from execution environment 'JavaSE-1.7' on the Java Build Path
In Installed JREs section in my Eclipse, default one is JDK 1.7.0_45. I also checked major version of my compiled java classes with
javap -verbose MyClass | findstr "major"
command and it is 51. But I get this exception below from Tomcat in ubuntu :
java.lang.UnsupportedClassVersionError: com/maozturk/MyClass : Unsupported major.minor version 51.0
Why am I getting this exception since version of them are same?
I still don't know exactly what problem is but it solved when I upgrade Tomcat to 7.0.52.
I know that topic is about Tomcat, but I had the same problem with Glassfish, maybe it could be helpful - I've changed java version for Glassfich to java 1.8 (after install it :) )