0

I'm trying to export and run a JavaFX project and after I export the project through Eclipse, resulting in the Jar being created I double click on it and I receive these two error messages from the JVM as pop-ups in windows. "Error: A JNI error has occurred, please check your installation and try again" and "A Java Exception has occurred."

This is the process that I followed to create the Jar file in eclipse.

ProjectName>Export>Java>Runnable JAR file> then selecting the export destination and using the default selected launch configuration. Library handling is selected as "Extract required libraries into generated JAR" and then Finish.

I receive the error messages after attempting to double click the Jar. Please forgive me if this is not the correct process for running the Java program as this is my first time attempting this.

I attempted to download launch4j, and follow this guide, https://medium.com/mpercept-academy/how-to-make-a-executable-file-from-your-java-code-3f521938ae5c, to run it as a .exe in windows but after selecting the minimum JRE as 1.7.0, creating the .exe, and attempting to run it I get a message "JRE 1.7.0 required".

I also attempted to use this script but it was previously used on a Mac and I'm not sure how to create a script equivalent that will work in PowerShell for windows.

export PATH_TO_FX_MODS=/Users/mh6624pa/Documents/javafx-jmods-15.0.1 jlink --module-path $PATH_TO_FX_MODS:bin/edu.ics372.pa2 --add-modules=edu.ics372.pa2 --output pa2 pa2/bin/java -m edu.ics372.pa2/edu.ics372.pa2.DrawDiamond

Here are some details regarding my setup. Corretto 11.0.8.10.1 JavaFX SDK 16 JavaFX-jmods 17.0.0.1 but not sure if I need the jmods or if I do how I would go about using it to make the executable work. Windows 10

When I run the program in eclipse I don't have any compile-time or runtime errors. I'm not sure if it's an issue with the code or if I just don't know how to correctly create the executable. Let me know if you need to see the code or any other details regarding my setup.

[update] I've updated Java JDK to 16 and messed around with the build path and now I am not seeing the error messages anymore but now neither of the .exe or .jar files do anything when clicked.

YHapticY
  • 177
  • 11
  • Perhaps try [JPackageScriptFX](https://github.com/dlemmermann/JPackageScriptFX), or at least take a look at it and see if if it is the kind of thing you want to do. I think just getting eclipse to export a jar is likely not going to end up being the way you distribute your app. – jewelsea Sep 19 '21 at 08:07
  • Perhaps a duplicate of [How can I create a Windows .exe (standalone executable) using Java/Eclipse?](https://stackoverflow.com/a/69050509/1155209). That question is about exe filed and the title of this question is jar files but the body talks about exe files. I linked my answer to the related question because other accepted answers are obsolete. – jewelsea Sep 19 '21 at 08:13

1 Answers1

0

I was able to figure it out. I needed to use the following script to create an executable in Windows.

C:\path\to\jlink --module-path C:\path\to\javafx-jmods version;C:\path\to\jdk;path\to\class\files\in\project -output C:path\to\where\you\want\executable\created

YHapticY
  • 177
  • 11