How to create Apache Maven project with JavaFX 8 and FXML support

JDK 8 comes with better JavaFX support. Creation of maven project which supports JavaFX is really easy now.




Create maven project

At first create a new maven Java Application project in your favorite IDE.

Modify pom.xml

Insert section below before element <project> in your pom.xml and modify <finalName> and <mainClass> by your project.

The most important maven plugin in a pom.xml is “JavaFX Plugin”, you can do with them amazing things such as creates MSI, DEB and RPM packages and much more. Please see documentation for the plugin



Create project structure

In JavaFX project are java classes stored in src/main/java and FXML, CSS, images, etc. in src/main/resources. There is example of these structure (base package is: org.korecky.myjavafx

│   pom.xml
        │   └───org
        │       └───korecky
        │           └───myjavafx
        │               │
        │               └───fxml


You are now done.
You can write your code now.



Resources which helped me wrote this guide:
From Zero To JavaFX In 5 Minutes
Thanks Carl J. Mosca for help with classpath problem.

One thought to “How to create Apache Maven project with JavaFX 8 and FXML support”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.