Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX 2 as a Maven dependency [duplicate]

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....

like image 946
mikera Avatar asked Feb 15 '12 13:02

mikera


2 Answers

No, such a solution doesn't exist for the moment. I doubt that it will ever, since as from Java 1.7 update 2, JavaFX is installed together with the JVM. Plans are to include JavaFX in the JRE as from Java 1.8 (next year). From then on, you wouldn't need a dependency at all.

However you can use Maven with JavaFX now already, because Maven can call Ant tasks (antrun plugin) and there are super Ant tasks available with the JavaFX distribution. I blogged about it, but it's in French: Creer un projet Maven pour JavaFX2. It walks you through the whole process. Nevertheless, if you don't understand French, leave a comment on the article and I will try to help you or look in here in the Oracle forum

like image 22
estiedi Avatar answered Oct 04 '22 04:10

estiedi


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> 
like image 111
Andreas Stotter Avatar answered Oct 04 '22 05:10

Andreas Stotter