1

I'm using Launch4j to make an .exe file from a .jar file. However, when I give it to a friend, it keeps getting that error "A JNI error has occurred, please check your installation and try again". I think I have a problem with JRE and JDK versions. So I saw this question, but it's too old and now Oracle from JDK11 does not have a separate JRE as before.

I was wondering which minimum JRE version should I put in the launch4j program (it is mandatory) and how to solve that error that my friend keeps getting?

Just to make clear. I can run the .exe file without any error, but when I hand it to my friend, they get that error mentioned above.

Mark Rotteveel
  • 82,132
  • 136
  • 114
  • 158
Panagiss
  • 695
  • 6
  • 15
  • Does this answer your question? [A JNI error has occurred, please check your installation and try again in Eclipse x86 Windows 8.1](https://stackoverflow.com/questions/22381202/a-jni-error-has-occurred-please-check-your-installation-and-try-again-in-eclips) – MarsAtomic May 17 '20 at 21:02
  • no, because my question is related with launch4j program. I get the same error but when trying to run a .exe file, not a .java file from Eclipse – Panagiss May 17 '20 at 22:20

1 Answers1

2

It seems like the code is compiled with JDK 11, but your friend doesn't have JRE/JDK 11, hence the error. The answer hasn't really changed since the question you linked. (bundle the JRE alongside your EXE and use the bundled JRE)

As for getting JRE 11 to bundle, you're correct that there is no longer an "Oracle JRE 11" that you can download anywhere. You can either use jlink to create your own JRE distribution, or you can use the OpenJDK JRE 11 download.

It seems the second option is a lot easier, so you can just download the JRE 11 from AdoptOpenJDK, and bundle that alongside your EXE.

a.deshpande012
  • 677
  • 8
  • 18
  • so OpenJDK let's you download JRE11? What is the purpose of OpenJDK and how there are different with the normal jdk? I will try you answer and get back with feedback – Panagiss May 17 '20 at 22:22
  • 1
    Yes, AdoptOpenJDK provides a JRE 11 download. OpenJDK is different than the Oracle JDK since OpenJDK is open source, while the Oracle JDK isn't. They are under different licenses, and the new Oracle JDK license is more restrictive than OpenJDK. They are both maintained by Oracle. – a.deshpande012 May 17 '20 at 22:26