Friday Jul 20, 2012

JavaFX Deployment News!

One of the issues developers face almost everyday is the proliferation of Java platforms. Questions like: What version of Java should I use? Should I use the latest features? What about companies that are still running old versions of Java? These are common questions among developers, and just determining the Java release to be used could require much thought.

The majority of developers want to go for the latest build, but most of the time their companies are using older releases of the platform, and upgrading is out of question as it might break some of the older applications. Sometimes, developers don’t even have the rights to update the software, preventing them from writing powerful applications using the latest technologies that they desire.

Well, not anymore. With the JavaFX packager your deployment nightmares are gone! The newest packaging tool for JavaFX applications allows you to bundle your application along with its resources into a package that include a private copy of the Java and JavaFX runtimes, together with a native application launcher. This means you won’t have to worry about what is installed on the machine on which your application is going to run; your application’s package includes everything it needs for execution! Because it has its own private copy of Java and JavaFX runtimes, you don’t have to be concerned about breaking other applications, or asking your client to update the system to be able to run your application. Your application is self contained and ready to be used.

The javafxpackager will generate zip files or native packages depending on the operating system on which your application will be running. For example, if you are running on Windows it could generate EXE or MSI files. On MacOS it would generate a DMG file, and on Linux it would generate an RPM file.

JavaFX Packaging Tool

JavaFX 2.2 provides two options to create your bundles: The command line utility tool javafxpackager, and a set of ant tasks ant-javafx.jar

Before we go any further let’s review the build process for JavaFX applications.

JavaFX applications and preloaders consist of source code, stylesheets, and may or may not contain additional resources. Source code must be compiled, and stylesheets can optionally be converted to binary format. The source code, stylesheets, and other resources are combined to create a JAR archive, which can optionally be signed and have a certificate attached. JavaFX applications and preloaders are packaged into separate JAR archives. For web applications, a deployment descriptor (JNLP file) is prepared to produce the final package, consisting of one or more executable JAR files, the deployment descriptor, and a web page with the embedded application or a link to launch a Web Start application.

You have full control of this process through the JavaFX packager tool or the ant task as shown in the following table.

Now that you know how to package your JavaFX application, there is a small option you need to include in order to produce the application native bundles:

This is an example of the ant task including the generation of native bundles:

nativeBundles can have the following values:

  • image: Bundle of the application in an unpacked form. You can zip it or package it for redistribution.
  • installer: prepackaged image
  • all: generate images and installers

Now that you have generated your native packages, you can install and test your application. For example for Mac OS we have the following default installer:

In addition, you can customize the bundles and have something like this:

For the bundle customization you will need to place resources such as icons in the package/<platform>/ folder:

  • package/macosx/Ensemble2.icns
  • package/windows/Ensemble2.icns

You might also include customs scripts to be used to build the packages:

  • package/macosx/Ensemble2-dmg-setup.scpt
  • package/windows/Ensemble2.wsx

The native packaging capabilities described in this article are available in JDK 7u6 and subsequent releases. I hope you’ll try out these capabilities, leveraging them to make it easy for users to deploy your JavaFX applications!

I'm BACK!!!!

Hello everyone, let me start this blog by saying: “I’m back!!!”. It’s been an amazing decade as Java Evangelist, and now it’s time to really start writing my blog!! From now on, you will find in this space all about my trips, experiences with developers, and lots and lots of information about Java Technology.

So stay tuned!!!


Angela Caicedo


July 2012 »