adam bien's blog

How To Compile Java FX 2 Applications With Maven 3 📎

Java FX 2 is Java. To build a Java FX application you only need an additional JAR: jfxrt.jar which contains the Java FX UI classes. The JAR comes with Java FX SDK, but is not included in the public maven repository. You can point to the Java FX SDK installation with Maven's system scope dependency:

<project>
...
    <dependencies>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>javafx</artifactId>
            <version>2.0</version>
            <systemPath>${fx.home}/rt/lib/jfxrt.jar</systemPath>
            <scope>system</scope>
        </dependency>
    </dependencies>
</project>

The resolution of the ${fx.home} variable ensures the pom.xml independency on user-specific settings:

<settings>
...
<profiles>
        <profile>
            <id>javafx</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <fx.home>[PATH]/javafx-sdk2.1.0-beta/</fx.home>
            </properties>
        </profile>
    </profiles>
</settings>