1
votes

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?

2
Try embedding the specific jre in the jarRajat
I already attached JRE folder with my application. First i copied this folder to my application folder then in JRE path option, i provided "jre" path. Here is the folder that i copied: C:\Program Files\Java\jdk1.8.0_171\jreZain Ul Abidin
As far as i have remember we don't have to manually copy the jre in launch4jRajat
@RajatVerma I have updated the question. I have added the log that is generated by launch4j after running exe. Please check it out. Many thanks :)Zain Ul Abidin

2 Answers

3
votes

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.

1
votes
  1. Right clicked on my project in eclipse
  2. Go to Properties
  3. Go to java compiler
  4. uncheck "Use compliance from execution environment"
  5. Select the compiler compliance level to 1.4

Now create its Jar and convert to .exe , It worked for me.