0

I've created a JavaFX Application in IntelliJ for the first time. To that end, I've imported the JavaFX libraries into my project libraries and built a jar from my project. Then I've used Launch4j to wrap it as an executable file with following JVM options:

--module-path /Users/myName/Downloads/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.fxml

On the PC I've created the application it obviously runs smoothly. If I want to use it on another computer, I run into the following exception when I try to launch it:

Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

My question is if the application can't be launched due to the path I've given in the JVM options (since this seems very 'local' you could say, I guess) and it tries to add modules from a place that doesn't exist on my other PC? If so, how can I fix it so the exe can be launched on any PC without issues, as in so I don't have to download the lib on any PC. So where should I place the lib of the SDK? Is there any default way to do this, or what's the cleanest way?

And if I'm completely wrong... What else am I missing? Is it a memory problem?

Apologies if this is a dumb question and thanks in advance!

Nikan
  • 1
  • 1
  • I havent used IntelliJ, but i guess it works the same as eclipse. `--module-path /Users/myName/Downloads/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.fxml ` is your run configuration, if you export a jar, this will not be considered. My advice is to convert your project to a maven project and add the JavaFX dependencies – Dahlin Apr 14 '21 at 15:24
  • I did that now :) And it does work! I used gradle before all that but for some reason it refused to work and since I had never used maven before I thought I might try adding the libraries manually and go from there... Considering that JavaFX was already causing problems. Now I regret going the long way of avoiding maven. Adding all dependencies via maven and then using a plugin to export a jar worked wonders. – Nikan Apr 14 '21 at 16:21
  • glad to hear :3 however, what plugin are you using to export the jar? – Dahlin Apr 14 '21 at 16:23
  • I'm using the maven assembly plugin that I read about from this question: https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven – Nikan Apr 14 '21 at 17:53
  • I never used an assembly plugin, I just include everything needed in the build path and simply export the jar, and it works – Dahlin Apr 14 '21 at 18:19
  • I'm not sure if this is an IntelliJ thing where you need the plugin... I think I did read somewhere that Eclipse is easier in some ways when it comes to exporting a jar. Worth reading up more on the whole building artifacts/maven and all, I suppose. – Nikan Apr 15 '21 at 11:31

0 Answers0