söndag 14 april 2013

Project "FXComparer" part 4 - Packaging the application

In this last part of the "FXComparer" series we will have a look at a Maven plugin called javafx-maven-plugin which we will use to package our application.

The javafx-maven-plugin is really easy to use and can be used to create among others executable JARs, native installers, and Windows BAT-files. In this post we will focus on the executable JAR.
<plugin>
  <groupId>com.zenjava</groupId>
  <artifactId>javafx-maven-plugin</artifactId>
  <version>1.5</version>
  <configuration>
    <mainClass>com.loop81.fxcomparer.FXComparer</mainClass>
  </configuration>
</plugin>
That is all we need to configure in our pom.xml to enable the plugin. However before we can create a binary we need to do some configuration to our environment.

  1. You need to use a JDK which is greater or equal to update 9.
  2. JAVA_HOME need to be specified to point to your JDK.
  3. Run mvn jfx:fix-classpath. You can read more about this here: https://github.com/zonski/javafx-maven-plugin/wiki. In short this is needed because the fxrt.jar is not included in the classpath by default.
When the environment is configured all we have to do is to run mvn jfx:build-jar and we will get a nice runnable JAR for our application. 

FXComparer version 1.0.2
This last part conclude the "FXCompararer" series. We have seen how we can use JavaFX to create a modern application. There is still some parts in the JavaFX API that needs some improvements. Mostly these are small things. As some example you can not change the text of a TableView when it is empty or you can not disable the scroll bars in the TableView. However all in all JavaFX is so much better then Swing and it will interesting to see where JavaFX ends up in the future. 

You find the "FXComparer" and all source code at https://code.google.com/p/fx-comparer/.

The articles in this series are the following:

Inga kommentarer:

Skicka en kommentar