How to add JavaFX library to IntelliJ IDEA and Java 11-14? – you won’t believe how easy it is!

You are currently viewing How to add JavaFX library to IntelliJ IDEA and Java 11-14? – you won’t believe how easy it is!
Share This Post, Help Others, And Earn My Heartfelt Appreciation! :)
4.9
(446)

In this tutorial I will show you how to add JavaFX library to IntelliJ IDEA. With Java 11, JavaFX libraries (javafx with intellij idea) were excluded from the JDK library, so to use it you need to download and manually attach the missing libraries to the project.

JavaFX download -> How to add JavaFX library to IntelliJ IDEA

To download the package, go to https://gluonhq.com/products/javafx/ and select the appropriate version for us. In my case it will be “JavaFX Linux SDK”.

The downloaded package should be unpacked. We will be adding these libraries to the project in the next steps.

How to add JavaFX library to IntelliJ IDEA and Java 11-14? - you won't believe how easy it is!

Setup JDK -> Java 11 and Java 14

In IntelliJ go to File -> Project Structure -> Project, and then set the appropriate JDK version.

How to add JavaFX library to IntelliJ IDEA and Java 11-14? - you won't believe how easy it is!

In the Modules tab, we also set the correct JDK.

How to add JavaFX library to IntelliJ IDEA and Java 11-14? - you won't believe how easy it is!

How do I add JavaFX to an existing project?

Then go to File -> Project Structure -> Libraries and add New Project Library by clicking the plus button +. Select the lib folder in the directory where we previously unpacked the JavaFX SDK library.

(We can also define this library as Global Libraries, and then only import to individual projects / modules).

How to add JavaFX library to IntelliJ IDEA and Java 11-14? - you won't believe how easy it is!

Launching the application

If you get an error when starting the application:

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

then you need to add the javafx.graphics module in the VM options (remember to change the path).

Linux

--module-path /home/pawel/Desktop/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.fxml

Windows

--module-path "C:\javafx-sdk-11.0.2/lib" --add-modules javafx.controls,javafx.fxml

It’s all! Run the app and see it works! 🙂

If you enjoyed this post please add the comment below and share this post on your Facebook, Twitter, LinkedIn or another social media webpage.
Thanks in advanced!

How useful was this post?

Click on a star to rate it!

Average rating 4.9 / 5. Vote count: 446

No votes so far! Be the first to rate this post.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments