问题
I created JAR file of my JavaFX application. JAR file is working perfectly fine without any error. But when i converted jar into exe using launch4j and tried to open exe file file it gives two errors:
Java Virtual Machine Launcher Error: A JNI error has occurred, please check your installation and try again.
Java Virtual Machine Launcher A Java Exception has occurred.
Here is the log:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Main has been compiled by a more recent version of the Java Runtime (class file version 54.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:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
Can anyone help me please?
回答1:
Actually i was selecting another version of JRE in launch4j while converting to exe. Now i attached the JRE which was installed on my system while developing the application and it's working perfectly fine.
回答2:
- Right clicked on my project in eclipse
- Go to Properties
- Go to java compiler
- uncheck "Use compliance from execution environment"
- Select the compiler compliance level to 1.4
Now create its Jar and convert to .exe , It worked for me.
来源:https://stackoverflow.com/questions/50075705/jni-error-occurred-after-converting-jar-to-exe-launch4j