I want to ask if there is any method to add JavaFX into Maven Archetype list in Eclipse or any plugin to use Maven to build JavaFX Application.
Create a Maven projectSelect File -> New -> Project -> Maven and enable Create from archetype . If the JavaFX archetype is not installed yet, select Add archetype... and set the groupId ( org. openjfx ), the artifactId ( javafx-maven-archetypes ), and the version ( 0.0. 6 ), and press OK.
Now, we need to configure Eclipse to execute the JavaFX applications. There are two ways of Eclipse Configuration for this purpose. We can either export the JavaFX jar files to every Java project or install a new software which can support the JavaFX project creation directly.
This answer is copied from the documentation at https://openjfx.io/openjfx-docs/#maven. More detailed information (including a full sample pom.xml reference) is available at the link provided.
The pom uses the JavaFX Maven plugin:
<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>HelloFX</mainClass>
</configuration>
</plugin>
</plugins>
Add the maven dependencies:
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13</version>
</dependency>
</dependencies>
Run the application (e.g. based on the HelloFX.java from the referred sample):
mvn clean javafx:run
Note regarding other outdated answers
com.zenjava
javafx-maven-plugin
are outdated, as that plugin is not coded to work with recent JavaFX versions. For Java versions 10+, the org.openjfx
javafx-maven-plugin
should be used. There is the javafx-maven-plugin which is available for maven.
When developing with Java 8 you just put that plugin as some build-plugin, without further dependencies.
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<mainClass>your.main.class.which.extends.javafx.Application</mainClass>
</configuration>
</plugin>
Calling mvn jfx:jar
creates your javafx-application-jar inside target/jfx/app/yourapp-jfx.jar
, or even creates native launcher (like EXE-file) when calling mvn jfx:native
.
Disclaimer: I'm the maintainer of the javafx-maven-plugin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With