I have a Maven project that just displays a graph on the xy axis. I want to change that graph to a Javafx 2.0 linechart to display the same data. I tried using the FEST-javafx-maven plugin, but I still cannot compile the code; the compiler cannot find all of the javafx.xxx imports.
Any help would be appreciated.
Update (Oct 6 2015)
Modern JavaFX versions (shipped with Oracle Java 8+) do not require any additional class path to use JavaFX. The JavaFX runtime is on the default classpath Java uses for compilation and execution. This means that a plain maven pom.xml file, with no additional dependencies, will build a JavaFX application.
However, if you wish to use additional packaging features for your application, such as the ability to deploy it as a self-contained application, then I advise using the (third party) JavaFX Maven plugin.
Previous Answer
The following information in this answer is now mostly old and outdated.
The link to the fest maven plugin I found (http://fest.easytesting.org/javafx/maven/) is to a tool for building JavaFX 1.x script projects, which is a completely different and incompatible beast to JavaFX 2.0 - I'm not sure if there is an updated version of the fest maven plugin which supports JavaFX 2.0.
There is currently no official support for Maven from Oracle, nor a version of JavaFX 2.0 in a publicly hosted Maven repository.
However, I have successfully built JavaFX 2.0 projects using maven in the past by using a system scoped dependency on the jfxrt.jar and (optionally) invoking the JavaFX ant tasks from maven.
If you are embedding your graph in an existing Swing application via a JFXPanel, then you don't need to use the JavaFX ant tasks. Add jfxrt.jar from the JavaFX runtime as a system dependency OR manually install it into your maven repository to use a non-system scoped dependency.
An example of the command to manually install the required JavaFX 2.0 runtime jar is:
mvn install:install-file -Dfile="C:\Program Files\Oracle\JavaFX 2.1.0 SDK\rt\lib\jfxrt.jar" -DgroupId=com.oracle.javafx -DartifactId=javafx -Dversion=2.1 -Dpackaging=jar
After running the above command, add the dependency to the jfxrt.jar file to your maven pom and your project compilation should resolve all JavaFX API references:
<dependency>
<groupId>com.oracle.javafx</groupId>
<artifactId>javafx</artifactId>
<version>2.1</version>
</dependency>
If you extend the JavaFX Application class and you want your application packaged for deployment via webstart, browser embedding or as a JavaFX installation aware clickable jar, then you should adapt your pom.xml file to execute the relevant JavaFX 2.0 ant tasks - http://code.google.com/p/willow-browser/source/browse/pom.xml demonstrates such an adaption.
These threads discuss JavaFX 2.0 maven support and provide further background info and samples:
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