JRE 281 cannot run OpenJDK compiled jar [duplicate] - java

This question already has answers here:
Class has been compiled by a more recent version of the Java Environment
(33 answers)
Closed 2 years ago.
I have compiled .jar using OpenJDK 13 which cannot be run by most recent JRE (281). is it okay?
(OpenJDK can run this .jar, but ordinary people won't use it)
This is the output:
$ ./java -jar HelloWorld.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld 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
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)

It seems self-evident:
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld 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
Why fight it?
If I were wanting to produce code for others to run, at the present time I'd still be using JDK 11 (=an LTS release from AdoptOpenJDK).

Related

JNI Error even though Java is the latest version

I've been trying to run a jar file with a class version 59.0, however it always gives me a JNI error saying I can only run class file versions up to 52.0
This is weird because I am on the latest version of Java and have restarted my computer.
This is the error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: MapConverter has been compiled by a more recent version of the Java Runtime (class file version 59.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)
Please help!
Nevermind, I was downloading the "latest" version of java from the wrong page. I'm running Java 8.

Apache James Installation Issue - java.lang.UnsupportedClassVersionError:

I am trying to install apache james 3.3.0 in windows 7 service pack 1, in which both jd 1.7, and 1.8 already installed. But while running the james i am getting the below error.
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/ja
mes/app/spring/JamesAppSpringMain : 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.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
jdk installation directory
This error comes from lower version of jvm. It means you are trying to run java 8 compiled jar with java 7 jvm.
Therefore java 7 says that class version is not recognized. You need to configure JAVA_HOME points 8 then re-run.
You can find what class version is supported by which jvm https://en.wikipedia.org/wiki/Java_class_file#General_layout
This worked for me: I added
wrapper.java.command=/toolbox/jdk1.8.0_192/bin/java
near the top of conf/wrapper.conf .

JNI error after converting jar to exe using launch4j

After using launch4j to convert my jar file into exe it gives me a JNI error that tells me to check my installation and try again after that it gives me another warning that says a java exception occured.
I've tried different ways such as choosing different options but it still doesn't work.
here is the log:
Exception in thread "main" java.lang.UnsupportedClassVersionError: fluidDynamicsProject/FluidDynamicSerial 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)
It means that the version of the JVM that is used by launch4j to run the program is less recent than the version of the compiler that compiled class fluidDynamicsProject/FluidDynamicSerial. You can try to set the minimum version in the launchj4 configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
...
<jre>
...
<minVersion>11.0</minVersion>
...
</jre>
</launch4jConfig>
Note that it's possible that launch4j doesn't support the latest versions of Java.
Or else, you can lower the target version you use to compile your classes.

Unsupported major.minor version 52.0 while trying to run an exe file [duplicate]

This question already has answers here:
Unsupported major.minor version 52.0 [duplicate]
(26 answers)
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 6 years ago.
GP is a .exe file that I downloaded from here. When I'm trying to run it, I receive the following error:
C:\GPP> gp -list
Exception in thread "main" java.lang.UnsupportedClassVersionError: pro/javacard/gp/GPTool : 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.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
C:\GPP>
How can I handle it? Should I remove JRE and install a newer or older version?
My Current version:
C:\GPP> java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
C:\GPP> javac -version
javac 1.7.0_21
C:\GPP>
Is it possible to force Java use an specific major.minor version to run a program?
You need to install a Java 8 runtime as the application you downloaded was compiled with Java 8 as target platform.

Unsupported minor.major version 51.0 [duplicate]

This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 8 years ago.
While running Java program it is giving me and minor.major version mismatch error. I have JRE6.0 installed in my PC and no JDK version installed.
The exception which I am getting is:
Exception in thread "main" java.lang.UnsupportedClassVersionError: otaclient/ClassFactory : 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.access$000(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 Intergrate.main(Intergrate.java:13)
Thanks in advance.
The code seems to be compiled on JDK 1.7. You need to be upgrade your JRE to run this code
That class is compiled with a JDK 7, try it yourself. Run:
javap -verbose otaclient.ClassFactory
If you see 'major version: 51', it is was compiled with a JDK 1.7, see the Version of Class File section.
I think the code you're trying to run was compiled with JDK 1.7, so you should upgrade your machine JRE to 1.7 or 1.8 to run it.

Categories

Resources