0

I have a JavaFX project created on Intellij Community edition and JavaFX SDK 11.0.2. It works perfectly when I click the green run button on Intellij and the program opens up. I was attempting to export it to a jar file and try to double click on it but nothing happens. I tried to open it on command line by doing java -jar myapp.jar but it says "Error: JavaFX runtime components are missing, and are required to run this application". This is how I created the jar file from the project.

  1. File -> Project Structure -> Artifacts -> click on the plus sign (+) -> Jar -> From modules with dependencies.
  2. Select the main class and OK. Followed by Clicking on the + sign and adding all files from the javafx bin folder to the File ( all the dll files).
  3. Go to Build -> Build artifacts -> Build. This generates the jar file but shows the above error.
craftdeer
  • 985
  • 5
  • 20
  • 36
  • Do you checked that the module-path is set to the appropriate JavaFX SDK lib folder? – fireandfuel Nov 09 '21 at 13:39
  • @fireandfuel yes in my Edit Configuration, the VM option points to the correct lib folder – craftdeer Nov 09 '21 at 14:24
  • @Abra The only manifest file throughout the entire project are inside src/META-INF/MANIFEST.MF and out/production/myprojectname/META-INF/MANIFEST.MF. Both only show two lines `Manifest-Version: 1.0` followed by `Main-Class: main.Main` – craftdeer Nov 09 '21 at 14:28
  • 1
    Please read [this answer](https://stackoverflow.com/questions/69854986/creating-a-runnable-jar-with-maven-using-java-swing-and-integrated-javafx-app/69860519#69860519), perhaps the info there can help you. – jewelsea Nov 09 '21 at 15:09
  • All I had to do was create a new class, called it "SecondMain.class" then call the first class from the SecondMain.class and then use the SecondMain.class when creating the artifact instead of the first one as shown above. Weird – craftdeer Nov 09 '21 at 21:05
  • Sounds like you likely ended up deciding to create a launcher class to run JavaFX off the classpath in an unsupported configuration as [detailed here](https://stackoverflow.com/questions/52653836/maven-shade-javafx-runtime-components-are-missing). – jewelsea Nov 09 '21 at 22:07

0 Answers0