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.
Related
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.
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).
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 .
I created a Junit test case using Eclipse and it works fine. I am trying to compile it using command line but can't seem to do it.
I was able to "compile" it fine..but now when I try to run it I get the following error:
JUnit version 4.8.2
Exception in thread "main" java.lang.NoClassDefFoundError: org/hamcrest/SelfDesc
ribing
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 org.junit.runner.Computer.getSuite(Computer.java:26)
at org.junit.runner.Request.classes(Request.java:69)
at org.junit.runner.JUnitCore.run(JUnitCore.java:117)
at org.junit.runner.JUnitCore.runMain(JUnitCore.java:98)
at org.junit.runner.JUnitCore.runMainAndExit(JUnitCore.java:53)
at org.junit.runner.JUnitCore.main(JUnitCore.java:45)
Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
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)
... 18 more
To run it I am using:
java -cp "E:/Android ADT/adt-bundle-windows-x86_64-20130219/eclipse/plugins/org.junit_4.8.2.v4_8_2_v20110321-1705/junit.jar;." org.junit.runner.JUnitCore SchedulerTest
The compilation worked fine, and for compiling I used:
javac -cp "E:/Android ADT/adt-bundle-windows
-x86_64-20130219/eclipse/plugins/org.junit_4.8.2.v4_8_2_v20110321-1705/junit.jar
;." SchedulerTest.java
When compilation works fine but you get java.lang.NoClassDefFoundError when running the code, that usually indicates a missing runtime dependency. As in this case, org.hamcrest.SelfDescribing is not used at compile time, but required at runtime.
hamcrest is usually bundled within the official junit.jar that you can download from junit.org, however your E:/Android ADT/adt-bundle-windows-x86_64-20130219/eclipse/plugins/org.junit_4.8.2.v4_8_2_v20110321-1705/junit.jar doesn't have it. Look for a hamcrest jar in the Android ADT plugins directory E:/Android ADT/adt-bundle-windows-x86_64-20130219/eclipse/plugins/ and include that in your classpath when you run your application.
That is, run like this:
java -cp "E:/Android ADT/adt-bundle-windows-x86_64-20130219/eclipse/plugins/PATH_TO_HAMCREST.jar;E:/Android ADT/adt-bundle-windows-x86_64-20130219/eclipse/plugins/org.junit_4.8.2.v4_8_2_v20110321-1705/junit.jar;." org.junit.runner.JUnitCore SchedulerTest
Finally, the unit test works fine in Eclipse because there hamcrest is part of the default classpath when you run unit tests.
When i compile and run my program in eclipse, it works.
When i run my .jar program on my personal computer (Windows 8 with java JDK 7), it works.
But when i'm trying to run .jar in others computers, it doesn't work.
So i tried to run with command line java -jar myjar
and i got this message which i can't understand
java -jar "Bureau\Application SNCF\SNCF.jar"
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
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.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 java.lang.ClassLoader.loadClassInternal(Unknown Source)
Does anyone understand this message error?
Thanks for your help
This is always caused by the conflict of different Java JDK at compile time and runtime, make sure you are using same JDK version to compile and run it.