2

I used the latest things, OpenJDK14, and OpenJavaFX 14 in IntellJ. I created a simple sample JavaFX application that has a few buttons and a table, and a few lines of code to create the window. Now, as for "artifacts", choosing "JavaFx Application" did not work. According to existing answers on StackOverflow, that option no longer works because latest JDK does not include JavaFX. So, I used the regular "JAR" option with "from modules with dependencies".

The generated JAR file was huge. It was 15MB. And only 1KB of which is my code. The content of the JAR is like below. Since the JAR is very big, I thought that it includes the JavaFX runtime, too. But when I copied the JAR to another computer (Ubuntu) and tried to run it, it failed with a message saying that JavaFX is needed. So, I installed JavaFX and then in worked.

My question is, if the JAR does not include JavaFX runtime, why is it so big? Or is it that the JAR does include JavaFX runtime but I my settings for the JAR are wrong and the included runtime is not recognised on the other computer?

enter image description here

Damn Vegetables
  • 11,484
  • 13
  • 80
  • 135
  • 1
    JavaFX runtime is not just the jars, it also has the native library dependencies. Making a fat jar will not make it runnable in this case. See https://stackoverflow.com/a/52673450/104891. – CrazyCoder May 04 '20 at 21:02
  • @CrazyCoder I did some test. I removed all JavaFX things in the artifacts settings (leaving only the project compile output), and rebuilt the JAR. Now the size became 2KB. I copied the jar to the other computer (Ubuntu), and it ran just as before with the same command (`... --module-path --add-modules javafx.controls, javafx.fxml ...`). So, I am not sure if those were necessary. The thing I installed (actually just extracted to a directory) were the 40MB JavaFX Linux SDK on the Gluon website. – Damn Vegetables May 05 '20 at 03:52

0 Answers0