JavaFX 2 as a Maven dependency

mikera picture mikera · Feb 15, 2012 · Viewed 83.6k times · Source

Is it possible to reference JavaFX 2.0 as a dependency in Maven in the pom.xml so that everything works smoothly?

I saw in this question that it is possible to install the jfxrt.jar locally, but ideally I'd like a simpler approach where the dependency can be properly resolved and downloaded without any local hacks....

Answer

Andreas Stotter picture Andreas Stotter · Nov 27, 2012

here is a possible solution.

Create a lib folder in your project directory and put the jfxrt.jar into that directory.

<dependency>
  <groupId>com.oracle</groupId>
  <artifactId>javafx</artifactId>
  <version>2.2.3</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/lib/jfxrt.jar</systemPath>
</dependency>

And if you want to build an executable jar you only need to include the javafx-maven-plugin. For further information see: link-to-github

<plugin>
      <groupId>com.zenjava</groupId>
      <artifactId>javafx-maven-plugin</artifactId>
      <version>1.3</version>
      <configuration>
          <mainClass>[put your application main class here]</mainClass>
      </configuration>
</plugin>