Plugins to ease the work with JavaFX 11+


After the release of JavaFX 11 under the OpenJFX project last September, we launched openjfx-docs as a starting guide to pave the way for developers that were facing new challenges, mainly JavaFX being outside the JDK and also being modular.

At the same time, we provided a number of samples to illustrate how to work with JavaFX 11+ from command line or from your favorite IDEs, either with non-modular or with modular applications.

Gradle

For those developers that use Gradle as build tool, we created the Gradle JavaFX plugin:

and now it is widely used for many projects, as it greatly simplifies the build file. Uses of this plugin can be found in many OSS projects that #WorksLikeHeavenOnJDK11, like:

Maven

On the other hand, in Maven we have been relying in the MojoHaus exec plugin and the exec:java goal. Given the fact that is not really modular, people have been recommended to use exec:exec instead, which requires extra configuration (adding some VM arguments like the module-path and required modules).

In order to simplify this process for the final developer, we decided that a Maven plugin equivalent to the Gradle plugin was in order.

The JavaFX Maven plugin

Today we have released the very first version of a Maven plugin for JavaFX 11 and beyond.

You can find it already in Maven Central, and you can start using it in your projects.

How to use it

In your Maven project, edit the POM file, add your JavaFX 11+ dependencies:

and now add the plugin:

To run the project, just run mvn javafx:run.

Any feedback is absolutely welcome, and you can file any issue you face in the plugin issue tracker.

Maven Archetypes

We were also aware that creating a JavaFX Maven project from scratch is cumbersome, and that the existing archetypes are not very up to the date.

So we have also created two new archetypes that will ease the way to create a regular JavaFX 11+ Maven project, either with or without FXML.

Since the archetypes are published at Maven Central, you can run the following on the command line to create a project that uses FXML:

It will create a project with a few classes. Running mvn javafx:run will let you test it.

Of course, you can also use your favorite IDE, add or search for the archetype and create the project. Then make sure you select the javafx:run goal to run it.

Again, any feedback is absolutely welcome, and you can file any issue you face in the archetypes issue tracker.

Conclusion

There is no excuse now to get you started using JavaFX 11+ on your projects! We have you covered!

If you haven’t done it already, visit openjfx.io, and get started with JavaFX 11.