I wrote not so simple app, and decided to make applet. I have the .jar archive and main class there is chat.java (it contains init() and extends JApplet). I have this code in HTML File:
<applet code="chat.class" archive="chat.jar" width="150" height="150">
Error!
</applet>
And it gives error
java.lang.UnsupportedClassVersionError: chat : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.defineClassHelper(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.access$100(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.UnsupportedClassVersionError: chat : Unsupported major.minor version 51.0
in Java console. I dont know what to do, my applet should open a new Frame (popup) where you can chat and so on.
Thanx for any replies!
You have incompatible version of the class file and the java plugin. For example you compile your code in java7 and trying to run in on java5 or java6.
The Unsupported major.minor version 51.0 means that you have compiled your code in JDK7, and your browser plugin i JRE 6 or older and does not understand it.
In such situation you need to do one of:
update your java plugin (or switch to proper version if you have more), or
compile your applet for the older java using '-target' option.
To check your java version go to plugin test page.
That exception means that you compiled your classes under a specific JDK, but then try to run them under older version of JDK. So, you can't run classes compiled with JDK 6.0 under JDK 5.0. Check your browser JRE version. Also you can specify a target JDK when compiling your classes.
Related
I have tried to create a web application project using IntelliJ IDEA and I am using a Glassfish 6.2.5 version as the server and JDK version is 1.8 but when I started the server it showed this error
Application Server was not connected before run
configuration stop, reason: Unable to ping server
at localhost:4848
is there someone who knows about this error please help me.
this is the log
C:\glassfish6\glassfish\bin\asadmin.bat start-domain domain1
C:\Users\Lakshitha\.jdks\corretto-1.8.0_312\bin\java.exe -Dfile.encoding=windows-1252 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2021.3.2\lib\idea_rt.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\Lakshitha\AppData\Local\Temp\idea_classpath1962225907 com.intellij.javaee.oss.process.JavaeeProcess 65261 com.intellij.javaee.oss.glassfish.agent.Glassfish51Agent
Error running admin process:
Message: com/sun/enterprise/admin/remote/RemoteSuccessException 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 Stack trace: java.lang.UnsupportedClassVersionError: com/sun/enterprise/admin/remote/RemoteSuccessException 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 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:756) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:473) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at com.intellij.javaee.oss.process.JavaeeProcess.main(JavaeeProcess.java:30) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:64) IDEA requires application server's bundled JDK to be 5.0+, please replace JDK manually
Process finished with exit code 0
[2022-04-27 04:13:03,148] Artifact Test WAP:war exploded: Waiting for server connection to start artifact deployment…
Detected server admin port: 4848
Detected server http port: 8080
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/glassfish/admin/cli/AsadminMain 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
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
C:\glassfish6\glassfish\bin\asadmin.bat stop-domain domain1
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/glassfish/admin/cli/AsadminMain 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
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Disconnected from server
The exception does not tell you that you need Java 8 but instead that Java 8 (class version 52) is too old to run classes compiled by version 55 (i.e. Java 11).
So you need to install JDK 11.
I compiled my program, but when i try to run it, i get this error :
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: Lanceur has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the J ava Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
I tried to "move" the JDK 13 all the way up in PATH, restarted my PC, but nothing changed. Here is a screenshot :
I then tried to download JRE 13, but can't find it anywhere.
How can i do this ?
I can't update to JDK 14 or up, because i need something that was removed in these versions
As you're compiling without a build environment, you'll need to build with:
javac -target 1.8 -source 1.8 MainClass.java
Java versioning is confusing but stick with 13 until you get used to it.
This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 3 years ago.
I have java versions 8 and 11 both installed. When I try to run any .java file in cmd using java command, I get the following message:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: aa 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
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
I've tried installing a newer version of java but nothing has changed.
Java 11 should support file format 55 (https://en.wikipedia.org/wiki/Java_class_file#General_layout). Type java -version on commandline to figure out if you are using the correct installation. If not change your environemnt variables accordingly.
This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 5 years ago.
This line of code in my Python file seems to return the error:
Could not find or load main class TestClass
TestClass.java is in the same folder as my .py file. Not sure what is going wrong. Any ideas?
process = Popen(['java', 'TestClass'], stdout=PIPE)
Edit: compiling the java file worked, however now i am getting the following error when trying to run it. i tested the java file directly and it worked fine, so it seems to be an issue with python to java versions? i am running java 8 latest build now, and latest build of python...
Exception in thread "main" java.lang.UnsupportedClassVersionError: TestClass : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoa`enter code here`der.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Your python script is looking for a compiled .class file, while you only have the uncompiled .java file.
I have created a jar file using JDK 8.0 and I tried to run the jar file in a system which is having JRE 7.0, but I am getting an error like this:
C:\Users\admin\Desktop>java -jar test.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: test : Uns
upported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
What change am I need to make in my jar file creation. So that it will run without version compatibility?
You need to use the -source option for javac. For example:
javac -source 1.7 foo/Bar.java
In theory you can specify the source and target options separately, but judging by your comment, it sounds like you can't use Java 8 language features at all when targeting 1.7.
Note that this only covers your own source code. If xbasej-20091203.jar was built against Java 8, you'll need to find a version which targets Java 7 instead.