• Nov
    • 24
    • 2012

From Zero to JavaFX in 5 minutes

Posted by In Enterprise, JavaFX

Over the last few weeks, I’ve been working on a new Maven Plugin for JavaFX. Using this plugin it’s much, much easier to get up and running quickly and to build complicated distribution bundles (such as executable JAR files, native installers and webstart bundles). Rather than tell you about it, here’s the steps to take you from nothing to a fully working, packagable JavaFX distribution.

Before starting you will need to have installed JDK 7 update 6 or later, and Maven 3.0 or later. This guide will walk you through that.

Step 1: Fix your Classpath

When you install the JDK currently, it includes JavaFX but does not put it on the classpath (yes this is weird – it will be fixed in Java 8). To fix this, open a Command Prompt and type:

mvn com.zenjava:javafx-maven-plugin:1.3:fix-classpath

This will ask you to confirm that you want to do this, type “y”.

You will need to do this only once for each development machine (and you will never need to do it on your users’ machines, only development ones).

Step 2: Create a New Project

Open a command prompt and go to a new workspace area (i.e. create a new directory to house your code), then type:

mvn archetype:generate -DarchetypeGroupId=com.zenjava /
-DarchetypeArtifactId=javafx-basic-archetype /
-DarchetypeVersion=1.1
You will be prompted for some parameters:
  • groupId: com.mycompany
  • artifactId: my-jfx-project
  • version: leave as default
  • package: com.mycompany.myjfx
This will create a new directory called “my-jfx-project” with some basic source code which you can use as a skeleton to get you up and running quickly.

Step 3: Run the Project

Change directory into your newly created project and use Maven to launch your application:

cd my-jfx-project
mvn jfx:run

You should see a basic hello world style dialog popup like so:

Note: this run command is just a pure wrapper around the maven exec plugin. There is no special JavaFX magic going on here, it’s just a convenience method.

Step 4: Edit the Project

You can now open the new project in your favourite IDE:

Since this a Maven application any dependencies you need will be downloaded, your classpath will be all setup for you and you simply can get stuck in and start editing, running and debugging your project.

The starter project includes some example FXML, basic logging and makes use of the very cool MigPane layout manager. All of this is just a guide, you can delete, edit, rename or do what you like to all of this code to create your perfectly customised JavaFX app.

Your project should look something like this, with MainApp being the main entry point that you run:

For tips on writing JavaFX applications see: http://docs.oracle.com/javafx/

For tips on using Maven to manage your dependencies: http://maven.apache.org/guides/getting-started/index.html

Step 5: Distribute your App

JavaFX applications can be deployed in a number of different ways – each option has it’s benefits and drawbacks - choose whichever option suits you.

Executable JAR file 

From the command line, and in the base directory of your project (where the POM file is) type:

mvn jfx:build-jar

Your executable JAR will be found at: {project.dir}/target/my-jfx-project-1.0-SNAPSHOT-jfx.jar

The Executable JAR file option is simple and handy as you can easily send the single JAR around to users and they can just double click it. It does require Java to be already installed on the user’s system though, and there’s no support for auto updating and advanced functions (like menu shortcuts, file associations, etc). Also be aware that if your jars contain files with the same name then they will clobber each other (see this issue)


‘BAT’ file (for Windows)

From the command line, and in the base directory of your project (where the POM file is) type:

mvn jfx:build-win-bat-bundle

A directory containing a Windows batch file  and all project JARs will be found at: {project.dir}/target/win-bat

The ‘BAT’ file option is great for quick demos, you can easily copy the directory to your demo machine and tweak the JAR files and scripts as needed. It does require Java to be already installed on the user’s system and java.exe being on the path, so it’s more for internal use than general end user consumption.


Webstart 

Webstart applications can either be signed, or unsigned. If they are not signed then they are limited by the browser’s sandbox. Most interesting applications will need to be signed and to do this you need to get a certificate to verify you are who you say you are.  For development this can be a pain, so the JavaFX Maven plugin includes the ability to generate a quick certificate for testing (i.e. you will be able to deploy but your users will see a “this app is not trusted” message when they run it).

To generate a certificate run the following command in the base directory of your project (change the domain, country code and state to match your details):

mvn jfx:generate-key-store -DcertDomain=com.yourcompany -DcertCountry=US -DcertState=WASHINGTON

You only need to do this once for your project and you can optionally check this development keystore into your source control so other developers can avoid this step.

To then build a Webstart bundle run:

mvn jfx:build-webstart

A directory containing  a HTML file, JNLP file and your signed JAR files will be found at: {project.dir}/target/webstart

You can copy this directory directly to any web server and point users at the HTML file to run your app. Both the HTML and JNLP files are built from velocity templates which you can customise to be anything you want.

The web-based distribution, and auto updating of Webstart are great in theory, but it doesn’t work that well in practice. Use webstart only if you have control over the operating environment (e.g. you are running within a corporate IT network and can control Java versions, etc). Don’t try to use it for delivery to the general public – it just won’t work and will cause you lots of grief.
 Some other things to be aware of with webstart  depoyment:
  • browser security issues means Java will always be auto-updated, your app may break at any time if a future version of JavaFX changes the way your app works
  • there is a trend away from browser plugins and this option is not likely to be supported on major browsers soon


Native Installers

To build the native installer for your current OS run:

mvn jfx:build-native

Your bundle will be built into: {project.dir}/target/bundles

Currently native installers require you to first manually download and install an extra packaging tool specific to your OS. e.g. on Windows you need to install WiX. See the JavaFX packaging guide for more info.

Native installers are a recent addition to JavaFX, basically wrapping your Java program in a native launcher for your platform (i.e. an ‘exe’ on Windows) and bundling this into a native platform installer (i.e. an ‘MSI’ package on Windows). The JRE is actually co-bundled into the installer so your user just installs your application and does not need to install Java separately. From the end user’s perspective the whole thing is ‘native’ and the fact that your app is a Java app is hidden from them completely.

This is a very powerful option and has a lot of promise (and is the approach I would recommend) but there are still a couple of drawbacks. The main one is that you can only build the distributable for the target platform on that platform, i.e. you can only build a Windows MSI on a Windows machine, and a Mac PKG on a Mac machine. Additionally you have to download and install a third-party packaging tool that the JavaFX packing tool uses under the hood (i.e. on Windows you have to download and install WiX). I am working on extending the Maven plugin to do this last step for you.

The other major drawback is that the JRE is currently very large (70MB+) making your distributables large. This is something the Java community is (very slowly) working on, and once I get the other parts of this plugin working I may also put some effort into fixing this – it should be possible to get the bundle size under 20MB.

Finally there is no auto-updating code as yet, so each release your users must uninstall the old version and install the new one. Again this is something on the JavaFX to-do list but it hasn’t got a lot of attention. If it is something that you want, best to raise it in the open JFX mailing list.

Native installers is where I intend to spend the most effort going forward as I believe it is the only real long term option for JavaFX. I plan to release a version of the Maven plugin that can automatically download WiX for you sometime in the next few weeks. After that I will look at options for doing something similar for Mac and Linux bundles. 

Conclusion

The Maven Plugin makes it simple to get up and running with JavaFX and to build distribution bundles.  Your projects are also IDE independent (i.e. developers can use IntelliJ, Eclipse or NetBeans on the same project without problems) and you get all the cool dependency assistance that has made Maven such a popular tool. There’s little reason not to use it.

The Plugin is quite new however and since I develop on Windows, it has not been tested on Mac and Linux. If you run into any trouble on these other platforms, please raise an issue (general testers on these platforms would be great).

Currently the plugin does not support Applets. This would be trivial to add but since Applets are virtually a dead technology I have not bothered. If this is something you would like to use, raise an issue.

I also have not added Mac/Linux shell script options (i.e. similar to the Windows BAT option). Again these would be trivial to add but I don’t have environments to test on. If you have a need for these, raise an issue (and by doing so you volunteer to be the tester).

Several more advanced features are either missing (e.g. including native third-party libraries) or not well documented (e.g. templating HTML and JNLP files). I will tick away at these as and when I have time and motivation. I’m just one guy working on this in my free time, after-hours though – there’s plenty of work to be done here so if anyone is interested in volunteering some time, let me know.

42 Comments

  • November 25, 2012

    Dan,

    Nice job! I am still a Windows user myself (& Ubuntu too). I plan to test your maven steps. This is so hard to get right and very critical on how cross platform JavaFX apps ultimately get onto the users desktop (device).

    Very nice write-up! Keep up the excellent work!
    Carl

  • tbee
    November 25, 2012

    Nice post! Always good to see Maven support being picked up.

    Tom

  • November 25, 2012

    Hi,
    great stuff. Also played with Maven and JavaFX dependency (http://www.guigarage.com/2012/10/building-javafx-applications-with-maven/) but this is a more complete solution. Like the run and distribute mechanism.

    Hendrik

  • November 25, 2012
  • November 25, 2012

    Hi,
    the Gradle plugin for JavaFX builds provides a folder pattern for bundle specific files when creating a native app / installer. I think it would be great if your plugin uses the same notation. Here is the link:
    http://speling.shemnon.com/blog/2012/10/23/conventions-and-configurations/

  • November 25, 2012

    Hi,

    nice Maven plugin! One small correction (Blog & GITHUB): The “archetype:generate” needs the version number as an additional argument (-DarchetypeVersion=1.1):

    mvn archetype:generate -DarchetypeGroupId=com.zenjava -DarchetypeArtifactId=javafx-basic-archetype -DarchetypeVersion=1.1

    Otherwise Maven 3 will show a list of other artifacts to select and does not start to generate.

    Cheers,
    Michael

  • November 25, 2012

    Thank you for your efforts. This is much needed and appreciated. I am happy to test on OS X and provide feedback on GitHub.

  • zonski Author
    November 25, 2012

    Thanks for all the positive feedback guys – glad you find this helpful. Looking forward to any and all feedback from testing, especially on non-Windows platforms.

    @Hendrik I had some initial conversations with Danno about being consistent with the Gradle plugin but it kind of petered out. I wasn’t too sold on the ‘package’ directory as the term clashes too much with a Java package in my mind. I went with ‘deploy’ instead. Conventions on directory structure is definitely a topic open for debate though, so if people have any opinions let me know (might be best to create an issue on GitHub and discuss it there – or if you are on the openjfx list there’s a thread you could reply to: http://mail.openjdk.java.net/pipermail/openjfx-dev/2012-November/004375.html).

    @Michael that’s a bit odd, I haven’t needed to do that on my test machines. Just out of interest what OS are you on and what version of Maven are you using. I can easily add the version reference to the docco but it would be nice if it always just picked up the latest so I don’t have to update it every time I release (cause I’ll forget for sure).

  • Ramy
    November 26, 2012

    Going through your steps I end up with this in the sample pom.xml:

    com.zenjava
    javafx-maven-plugin
    1.2

    Shouldn’t that be 1.3 and not 1.2?

    Ramy

  • zonski Author
    November 26, 2012

    It seems a few people are picking up an earlier version of the archetype when they run this (I was under the impression Maven would always use the latest version but seems to be random). I have added a specific version reference to the post above as per Michael’s earlier comment (thanks Michael).

    if anyone got a POM that has a reference to the JavafX Plugin as version “1.2″ you might find it easiest to create a fresh project. Or you can just edit your POM to be version 1.3 but also delete most of the other “configuration” options for the plugin as I cleaned up this part of it lot between version 1.2 and 1.3

    Let me know if you have problems.

  • jocke
    November 27, 2012

    Nice struggled with javafx and maven for two hole days. No more i guess.

  • zonski Author
    November 27, 2012

    @jocke I struggled with it for a year. This plugin is the offspring of that frustration (I’d rather be writing some cool animations ;) ).

    I hope it helps – and do provide feedback on what does and doesn’t work for you so I can improve it.

  • December 5, 2012

    Hi, Zonsky, you’ve done a very nice work!!

    I’ve a doubt. I opened the project in NetBeans 7.2, and saw that any javaFx class does not compile (I get “cannot find symbol”), but yet somehow the project runs in the IDE.

    How can make NetBeans recognize javaFx packges and stop giving compiler errors ??

    thanks

  • zonski Author
    December 5, 2012

    Hi Rafael,

    I don’t use NetBeans so I can’t say for sure what is going on but we can check and try a few things.

    First, you did run the “fix classpath” step above?

    That should put Java on the classpath of your JDK set via the JAVA_HOME variable by copying it into the ‘ext’ directory.

    Assuming you did this then the next thing to check is that your JAVA_HOME is set to the same JDK installation that your NetBeans project is pointing to. Double check both and make sure they match.

    If they both match then it might just be that NetBeans is not smart enough to pick up that a JAR has been added to the ext directory and you need to force it to refresh – maybe remove the JDK from NetBeans and re-add it if that is easy to do.

    And if all that doesn’t work then you should be able to just add the jfxrt.jar to your classpath. Go into the classpath settings of your project and add a JAR, then go into the JDK directory and pick the jfxrt.jar.

    Let me know how you get on. I can try installing and using NetBeans but I’d prefer not to as it is not an IDE I am fond of. If there are any other NetBeans users out there they might be able to comment as well.

    • December 5, 2012

      thanks for reply, Zonski,

      I did opt to install manually jfxrt.jar artifact. Looking good now :D

    • Randy Simons
      December 5, 2012

      I had similar issue, even though I did run the classpath fix. But simply restarting NetBeans did solve it; jfxrt.jar is now automatically picked up. Btw, NetBeans 7.3, currently in beta, has improved support for JavaFX FXML.

  • Slava
    January 4, 2013

    Hi, I’ve got a problem: it’s OK for me to make BAT-bundle, but when I’m trying to make executable JAR or native installer, build fails cause of the next exception:
    http://clip2net.com/s/2FKhg
    Do you have a clue what I am doing wrong?

    • zonski Author
      January 11, 2013

      Sorry, that stack trace has gone. I saw it briefly before but never had a chance to look into it.

  • Vemlat
    January 31, 2013

    How do I configure a preloader ?

    com.zenjava
    javafx-maven-plugin
    1.3

    net.sourceforge.squirrel_sql.client.Main
    net.sourceforge.squirrel_sql.client.gui.SquirrelSplashScreen

    The above doesn’t seem to work.

  • Nick
    February 4, 2013

    Having a minor issue. Got everything working, generating native Windows executable but with a problem. Command line arguments given to the exe wrapper don’t get passed through to the java main function. Hence I can’t pick up options to control the initial start of the program. Any thoughts?

  • Jimmy
    February 12, 2013

    I love the idea and the effort. Any plans on integrating any of the pull requests and bugfixes on github and releasing a new version since some of the bugs prevent me from using it so far.

  • boris
    February 27, 2013

    Awesome. A true “from zero to javafx” in 5minutes. Thanks !

  • dang
    March 13, 2013

    Hi Zonski,

    Thanks for this wonderful plugin.

    When I tried to run the project in eclipse it was not able to class MigPane:

    javafx.fxml.LoadException: java.lang.ClassNotFoundException: org.tbee.javafx.scene.layout.fxml.MigPane

    And when I changed code and created .jar (created UI without using fxml) then jar file is nor running and showing error message in popup: UNABLE TO FIND CLASS::: XXXX.MainApp.

    Could you please indicate where am I doing wrong.

    Thanks,
    Dang

  • Steve
    April 1, 2013

    Hi Zonski,

    Thanks very much for the plugin. It worked right out of the box for me.

    A web based deployment solution suits my environment well. I’m currently using the webstart deployment (jfx:build-webstart) but would like the to move to an embedded solution. I will take a look at your solution under ‘Support for running embedded in browser’.

    Thanks
    Steve

  • Pradeep
    April 8, 2013

    Hi
    This solution is great, but after creating native package, the default java icon is displayed , but I want to add customised icon in native package, So I have added in pom.xml the icon path but still not changed , like this I have added ${basedir}/src/main/deploy/icon.icns
    So please any help will appreciated for me.

    • Gael
      May 10, 2013

      Hi Pradeep,
      until Zonsky has the time to reply with correct answer, my reply here might help you: http://stackoverflow.com/a/16477177/2369008

      In short: use the deploy-dir with path as installer expects, but not the icon-tag in pom.xml which seems to be for webstart.

  • Serguei
    May 19, 2013

    The installation fails on OS X 10.8.3, jdk 1.7 (see version details below):

    mvn com.zenjava:javafx-maven-plugin:1.3:fix-classpath

    …packages downloads started….

    Are you sure you want to continue? (y/n)
    y
    [WARNING] Fixing JRE bootclasspath to include JavaFX runtime and native files
    [WARNING] All applications using JRE will be affected: /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre
    [INFO] Copying JFX Runtime JAR ‘/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/lib/jfxrt.jar’ to ‘/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/lib/ext’
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 17.772s
    [INFO] Finished at: Sun May 19 14:47:02 CEST 2013
    [INFO] Final Memory: 5M/100M
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal com.zenjava:javafx-maven-plugin:1.3:fix-classpath (default-cli) on project standalone-pom: Error while copying JFX Runtime JAR ‘/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/lib/jfxrt.jar’ to ‘/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/lib/ext’: java.nio.file.AccessDeniedException: /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/lib/ext/jfxrt.jar -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

    Here is my Maven and Java details:

    serge-mac:~ serge-mac$ mvn -v
    Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
    Maven home: /usr/share/maven
    Java version: 1.7.0_21, vendor: Oracle Corporation
    Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre
    Default locale: en_US, platform encoding: UTF-8
    OS name: “mac os x”, version: “10.8.3″, arch: “x86_64″, family: “mac”

    Any ideas on how to fix that ? I have an impression that all that stuff JavaFX & JemmyFX are heavy coupled to Windows environment, at least all the existing examples prove that. Right ?

    Thank you.

  • Serguei
    May 19, 2013

    The same error when using mvn command on Windows 7 PC:

    If you want to run this command without seeing this warning use -DsilentJfxFix=true

    Are you sure you want to continue? (y/n)
    y
    [WARNING] Fixing JRE bootclasspath to include JavaFX runtime and native files
    [WARNING] All applications using JRE will be affected: C:\Program Files\Java\jdk1.7.0_21\jre
    [INFO] Copying JFX Runtime JAR ‘C:\Program Files\Java\jdk1.7.0_21\jre\lib\jfxrt.jar’ to ‘C:\Program Files\Java
    \jdk1.7.0_21\jre\lib\ext’
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 13.293s
    [INFO] Finished at: Sun May 19 21:09:07 CEST 2013
    [INFO] Final Memory: 5M/15M
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal com.zenjava:javafx-maven-plugin:1.3:fix-classpath (default-cli) on project stan
    dalone-pom: Error while copying JFX Runtime JAR ‘C:\Program Files\Java\jdk1.7.0_21\jre\lib\jfxrt.jar’ to ‘C:\P
    rogram Files\Java\jdk1.7.0_21\jre\lib\ext’: java.nio.file.AccessDeniedException: C:\Program Files\Java\jdk1.7.
    0_21\jre\lib\jfxrt.jar -> C:\Program Files\Java\jdk1.7.0_21\jre\lib\ext\jfxrt.jar -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

  • Mario
    May 27, 2013

    Hii Serguei ,

    had the same problem (damn restricted access from Windows 8).
    Use Windows PowerShell as Administrator will solve it.

    Don’t know right system in MacOs, but if there is an admin option try it.

    Greetz
    Mario

  • June 11, 2013

    Stage 3 works fine for me but stage 5 fails when I run the jar. I am running on Ubuntu 12.04. Any ideas how to fix? Shame because it looks like a really great plugin.

    It seems to be related to this issue here:
    http://stackoverflow.com/questions/12141022/how-to-skin-custom-controls-in-javafx-2-2-without-causing-css-warnings

    ~/workspace/zenjava/my-jfx-project$ java -jar target/my-jfx-project-1.0-SNAPSHOT-jfx.jar
    INFO MainApp – Starting Hello JavaFX and Maven demonstration application
    DEBUG MainApp – Loading FXML for main view from: /fxml/hello.fxml
    DEBUG MainApp – Showing JFX scene
    WARNING: com.sun.javafx.css.StyleHelper calculateValue Could not resolve ‘a lookup value’ while resolving lookups for ‘-fx-font’ from rule ‘*.label’ in stylesheet jar:file:/home/mark/workspace/zenjava/my-jfx-project/target/my-jfx-project-1.0-SNAPSHOT-jfx.jar!/styles/styles.bss
    Exception in Application start method
    WARNING: com.sun.javafx.css.StyleHelper calculateValue Could not resolve ‘a lookup value’ while resolving lookups for ‘-fx-font’ from rule ‘*.label’ in stylesheet jar:file:/home/mark/workspace/zenjava/my-jfx-project/target/my-jfx-project-1.0-SNAPSHOT-jfx.jar!/styles/styles.bss
    java.lang.NullPointerException
    at java.lang.Enum.compareTo(Enum.java:178)
    at com.sun.javafx.css.StyleHelper.lookupFont(StyleHelper.java:2035)
    at com.sun.javafx.css.StyleHelper.lookup(StyleHelper.java:1019)
    at com.sun.javafx.css.StyleHelper.transitionToState(StyleHelper.java:861)
    at javafx.scene.Node.impl_processCSS(Node.java:7415)
    at javafx.scene.Parent.impl_processCSS(Parent.java:1153)
    at javafx.scene.Node.processCSS(Node.java:7383)
    at javafx.scene.Node.processCSS(Node.java:7377)
    at javafx.scene.Node.processCSS(Node.java:7377)
    at javafx.scene.Scene.doCSSPass(Scene.java:446)
    at javafx.scene.Scene.access$3800(Scene.java:170)
    at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2202)
    at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:363)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:460)
    at com.sun.javafx.tk.quantum.QuantumToolkit$9.run(QuantumToolkit.java:329)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:82)
    at java.lang.Thread.run(Thread.java:722)
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.javafx.main.Main.launchApp(Main.java:642)
    at com.javafx.main.Main.main(Main.java:805)
    Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
    at java.lang.Thread.run(Thread.java:722)
    Caused by: java.lang.NullPointerException
    at java.lang.Enum.compareTo(Enum.java:178)
    at com.sun.javafx.css.StyleHelper.lookupFont(StyleHelper.java:2035)
    at com.sun.javafx.css.StyleHelper.lookup(StyleHelper.java:1019)
    at com.sun.javafx.css.StyleHelper.transitionToState(StyleHelper.java:861)
    at javafx.scene.Node.impl_processCSS(Node.java:7415)
    at javafx.scene.Parent.impl_processCSS(Parent.java:1146)
    at javafx.scene.control.Control.impl_processCSS(Control.java:1154)
    at javafx.scene.Parent.impl_processCSS(Parent.java:1153)
    at javafx.scene.Node.processCSS(Node.java:7383)
    at javafx.scene.Scene.doCSSPass(Scene.java:446)
    at javafx.scene.Scene.preferredSize(Scene.java:1449)
    at javafx.scene.Scene.impl_preferredSize(Scene.java:1516)
    at javafx.stage.Window$9.invalidated(Window.java:716)
    at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:127)
    at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161)
    at javafx.stage.Window.setShowing(Window.java:779)
    at javafx.stage.Window.show(Window.java:794)
    at javafx.stage.Stage.show(Stage.java:229)
    at com.mycompany.myjfx.MainApp.start(MainApp.java:34)
    at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
    at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:82)
    … 1 more

    • June 11, 2013

      Web start fails for me also. I get “Application Error: Unable to launch the application”

      java.io.FileNotFoundException: /home/mark/workspace/zenjava/my-jfx-project/target/webstart/${app.jnlpFileName} (No such file or directory)
      java.io.FileNotFoundException: /home/mark/workspace/zenjava/my-jfx-project/target/webstart/${app.jnlpFileName} (No such file or directory)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.(FileInputStream.java:138)
      at java.io.FileInputStream.(FileInputStream.java:97)
      at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
      at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
      at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
      at com.sun.deploy.net.BasicHttpRequest.doGetRequest(Unknown Source)
      at com.sun.javaws.jnl.LaunchDescFactory._buildDescriptor(Unknown Source)
      at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
      at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
      at com.sun.javaws.Main.launchApp(Unknown Source)
      at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
      at com.sun.javaws.Main.access$000(Unknown Source)
      at com.sun.javaws.Main$1.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:722)
      java.io.FileNotFoundException: /home/mark/workspace/zenjava/my-jfx-project/target/webstart/${app.jnlpFileName} (No such file or directory)
      java.io.FileNotFoundException: /home/mark/workspace/zenjava/my-jfx-project/target/webstart/${app.jnlpFileName} (No such file or directory)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.(FileInputStream.java:138)
      at java.io.FileInputStream.(FileInputStream.java:97)
      at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
      at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
      at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
      at com.sun.deploy.net.BasicHttpRequest.doGetRequest(Unknown Source)
      at com.sun.javaws.jnl.LaunchDescFactory._buildDescriptor(Unknown Source)
      at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
      at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
      at com.sun.javaws.Main.launchApp(Unknown Source)
      at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
      at com.sun.javaws.Main.access$000(Unknown Source)
      at com.sun.javaws.Main$1.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:722)
      JNLP Ref (…): NULL !
      #### Java Web Start Error:
      #### null

      • June 11, 2013

        Ahh .. I edited index.html and it worked. Not sure why it did not pick up ${app.jnlpFilename} automatically

    • zonski Author
      June 11, 2013

      Try with css2bss set to false so that it doesn’t compile your CSS into binary format. This looks like a problem in the JFX side of things rather than the plugin.

  • LittleEndian
    June 15, 2013

    Hello,
    I think it is a great idea. I tried to run: mvn com.zenjava:javafx-maven-plugin:1.3:fix-classpath and it completes succesfully. But when I run: mvn jfx:build-jar an error occures:

    [ERROR] No plugin found for prefix ‘jfx’ in the current project and in the plugin groups [org.apache.maven.plugins, org.
    codehaus.mojo] available from the repositories [local (C:\Users\[user_name]\.m2\repository), central (http://repo.maven.apach
    e.org/maven2)] -> [Help 1]

    How can I fix this problem?

  • Tom
    August 6, 2013

    I love it when things just work! Never had much to do with client-side GUI Programming and having an example with maven up and running in 5 Minutes is invaluable! Thanks!

  • Zulfy
    August 31, 2013

    Thanks for the wonderful plug-in. I have followed the steps and work smoothly..

  • September 19, 2013

    It’s an amazing article in support of all the internet
    visitors; they will get advantage from it I am sure.

Leave a Comment