3

I've build executable jar using NetBeans IDE 11.0 but when I open jar using :

hemlata@hemlata-pc:~/NetBeansProjects/Sizing/dist$ java -jar Sizing.jar 

I'm getting

Error: JavaFX runtime components are missing, and are required to run this application

I'm using OpenJDK 11 and OpenJFX 11 on Debian 10

I've added modules in vm option

--module-path /usr/lib/jvm/openjfx11/lib/ --add-modules javafx.controls,javafx.fxml  

But this is not problem.

So how to configure JavaFX runtime components that are missing?

Hemlata
  • 187
  • 2
  • 9
  • Class `javafx.application.Application` is in module `javafx.graphics`. – Abra Feb 22 '20 at 15:47
  • @Abra I'm not getting javafx.application.Application and it is resolved using mentioned modules, even tried but nothing is changed. – Hemlata Feb 22 '20 at 15:59

2 Answers2

5

I still wonder why Oracle removed JavaFX from the Java distribution and made life for us JavaFX developers such a pain.

But I would recommend to use the Java distributions from Bell soft these distributions have JavaFX included and work out of the box.

Waverick
  • 1,955
  • 1
  • 11
  • 12
  • Yes, they have, you will have to download the correct version, eg. https://download.bell-sw.com/java/11.0.6+10/bellsoft-jdk11.0.6+10-windows-amd64-full.zip – Waverick Feb 23 '20 at 10:01
  • Great I checked for LibericaFX and found those packages. Thanks a lot. I also found ZULU community JDK from AZUL provide ZULUFX but still doesn't have with JDK 11 but JDK 8 LTS is available. https://cdn.azul.com/zulu/bin/zulu8.44.0.13-ca-fx-jdk8.0.242-linux_x64.tar.gz thanks a lot for you answer my experience will be better using them. – Hemlata Feb 23 '20 at 13:18
  • Hopefully the JDK 14 also brings back a working native packager for JavaFX. After JDK 8 this was also removed. Oracle should understand that sometimes less isn't more. – Waverick Feb 23 '20 at 16:47
  • But we really don't need Oracle JDK for production use. I've checked ZULU JDK LTS that support till 2027. So may we expect if they'll include JavaFX from 14 and will continue in 15 16 and so on? – Hemlata Feb 23 '20 at 17:21
  • I know from bellsoft that they will supply future JDK's with JavaFX included. – Waverick Feb 23 '20 at 22:27
  • That's great. Thank you so much. – Hemlata Feb 24 '20 at 06:15
  • How, to use JavaFX from Liberica? I installed it and connected to Idea, but it can't find any packages, my app is non modular. – Simon Mar 29 '20 at 11:34
  • @Simon create simple java project not java FX and then add fxml and run that doesn't need to add vm arguments. – Hemlata Apr 21 '20 at 19:39
  • @Hemlata already figured out, my problem was I downloaded the Liberica JDK without built in JavaFX – Simon Apr 22 '20 at 16:12
  • @Simon Yes I also downloaded only JDK and later I did full version of it. But still we can not create JavaFX project we need to create simple Java project and then add FXML to do – Hemlata Apr 22 '20 at 16:20
  • I use Netbeans 11.3, using a JDK14 + JavaFX. Just create a normal Java application. (JavaFX templates aren't supported since NB8). The "main" class should inherit from javafx.application.Application and call the static method "launch" – Waverick Apr 22 '20 at 18:30
  • Thanks!! I just uninstalled all the stuff which came from the debian repo, `sudo apt remove openjfx` and `sudo apt remove default-jdk`, went to https://bell-sw.com/pages/downloads/ and downloaded the .deb for the full java JDK and now it's all working! – cardamom Jun 14 '20 at 19:05
0

I think the VM arguments are the problem because they are only added when executing your project from within the IDE.

If you build an executable jar from your project the VM arguments are not exported (because they are set in the command line and can't be exported like this).

If you change the command to start the jar like this it should work:

java -jar Sizing.jar --module-path /usr/lib/jvm/openjfx11/lib/ --add-modules javafx.controls,javafx.fxml  
Tobias
  • 1,762
  • 1
  • 10
  • 24