JavaFX 2.0 Beta Packager Tool Now Available

The latest JavaFX 2.0 Beta Build 38 release contains an interim version of the JavaFX Packager tool, an executable file in the \bin directory of the JavaFX SDK. This blog gives you some preliminary information about this tool. For other information about JavaFX deployment, see Deploying JavaFX Applications.

The tool can be invoked in either of two ways:

  • From the command line
    Set the Windows PATH environment variable to the \bin directory of your JavaFX SDK installation, then at the command line enter javafxpackagers with no options, which displays the help.

  • Using Ant tasks
    You can use the options from the javafxpackager command in your Ant tasks. See the example in Using the JavaFX Packager Tool with Ant Tasks.

The JavaFX Packager tool performs any of the following tasks from the command line or in Ant scripts:

Table 1 Types of Commands in javafxpackager Command and Ant Tasks

Task and Description Description javafxpackager Command
Parameter
Ant Task/Class

Make All

  • Compiles source files
  • Runs the Create JAR task.
  • Runs the Deploy task

-makeall

(Not Available)

Create a JAR Archive


  • Creates a JAR archive from compiled source files
  • Creates binary files from any CSS files

-createjar

FXJar task, FXJar class

Deploy (Generate Files for Web Deployment)


  • Generates JNLP and HTML files for web deployment

-deploy

DeployFXTask class

Convert CSS Files to Binary Format


  • Only converts CSS files to binary format

-createBSS

CSSToBinTask class

Sign JAR Files


  • Digitally signs JAR files with a certificate

(Not available in this release)

FXSignJarTask class


JavaFX Packager Commands

The following sections contain a description of the commands listed in Table 1.

Make All

The command-line version of the JavaFX Packager tool has a -makeall command, which is a convenience command to produce deployment files with minimal configuration. The -makeall command performs the following tasks:

  • Compiles the source files

  • Runs the -createjar command, which includes converting the CSS files to their binary form.

  • Runs the -deploy command, which generates the JNLP and HTML files.

  • Converts the CSS files to their binary form.

The -makeall command presumes all the application sources are located in the src directory and places the result files in the dist directory. You can set a limited number of other options, described in the command line help.

Prior to calling the packaging (Create Jar) and deployment tasks, the -makeall command compiles the source files as well. For compilation, it searches for a JDK installation in directories specified by the JAVA_HOME or java.home system variables and for a JavaFX SDK installation in directories specified by the JAVAFX_HOME or javafx.home system variables.

Create a JAR Archive

The Create JAR command in the JavaFX Packager tool packages files into an executable JAR file that contains the application. Other options you can set are described in the command line help.

By default, the Create JAR command also includes the JavaFX Launcher in the JAR archive. The JavaFX Launcher is responsible for locating the installed JavaFX Runtime and invoking the main application class using this Runtime. Use the -noembedlauncher option to keep the launcher from being embedded.

Deploy (Generate Files for Web Deployment)

The Deploy command generates HTML and JNLP files for web deployment scenarios. You can set the options described in the command line help. For more information about web deployment files, see Deploying JavaFX Application Files in the Deploying JavaFX Applications.

Convert CSS Files to Binary Format

Converting CSS files to binary form is by default included in the -createjar command functionality, but the -createbss command can be invoked independently if you only want to convert CSS files to binary form. You can specify the input and output files as options. See the command line help for the list of options.

Sign JAR Files

This command, currently available only through an Ant task, signs a JAR file with a certificate you provide. There are options to specify the keystore file, key alias in the keystore, keystore password, key password, and type of keystore. See the <fxsignjar> element in the example Ant script below.

About Source Files

The type of source files required for each command is shown in the following table.

Table 2 Source File Types According to Command or Task Type

Command Type Source File Types

Make All (command line only)

JavaFX code files and other application resources

Create Jar

Classes and other application resources

Deploy

JAR files and resources

Create BSS

CSS files

For Ant tasks, the source files for all commands are specified by the standard Ant fileset element, and for the command line interface the source files are specified by a combination of the -srcdir and -srcfiles parameters.

The -srcfiles option works in a similar manner as the Ant include option of the fileset element, in that if it is not present, all files in the preceding -srcdir are included, and if it is present, only files listed are included. For example, the following option includes both the temp\out.jar file and the content of the temp\dir2 and tmp directories:

-srcdir temp -srcfiles out.jar;dir2 -srcdir tmp

The command line version does not support advanced features of Ant, such as the **/*.html notation.

Using the JavaFX Packager Tool with Ant Tasks

Ant tasks can be configured in the same way as the javafxpackager command line options. The following example shows how the tasks and command line options are used in elements and attributes. Stay tuned for more documentation, coming soon.

Example 3-1 Ant Task Example Using JavaFX Packager Tool Options

<project name="HelloWorld" default="do-deploy" basedir=".">
    <target name="app-config">
        <property name="applet.width" value="600"/>

        <property name="applet.height" value="450"/>
    </target>
 
    <target name="init-fx-tasks">
        <property name="javafx.tools.ant.jar"
                  value="/javafx/jfx-deploy/artifacts/sdk/tools/ant-javafx.jar"/>
        <taskdef name="fxdeploy"
                 classname="com.sun.javafx.tools.ant.DeployFXTask"
                 classpath="${javafx.tools.ant.jar}"/>
        <taskdef name="fxjar"
                 classname="com.sun.javafx.tools.ant.FXJar"
                 classpath="${javafx.tools.ant.jar}"/>

        <taskdef name="fxsignjar"
                 classname="com.sun.javafx.tools.ant.FXSignJarTask"
                 classpath="${javafx.tools.ant.jar}"/>
    </target>
 
    <target name="do-deploy" depends="app-config, init-fx-tasks">
        <delete file="jar/HelloWorld.jar"/>
        <fxjar destfile="jar/HelloWorld.jar"
               applicationClass="helloworld.HelloRectangle" >
            <fileset dir="classes"/>

            <manifest>
              <attribute name="Implementation-Vendor" value="FX Team"/>
              <attribute name="Implementation-Title" value="HelloWorld"/>
              <attribute name="Implementation-Version" value="1.0"/>
            </manifest>
        </fxjar>

 
        <fxdeploy width="${applet.width}" height="${applet.height}"
                  outdir="deploy" embedJNLP="true"
                  outfile="HelloWorld"
            <info title="HelloWorld"
                  vendor="FX Team"/>
            <application name="HelloWorld"
                         appclass="helloworld.HelloRectangle"/>
            <resources type="eager">
               <fileset dir="jar">
                  <include name="HelloWorld.jar"/>

               </fileset>
            </resources>
        </fxdeploy>
        <genkey alias="TestAlias" storepass="xyz123" 
            keystore="sign/test.keystore"
            dname="CN=Deploy, OU=JavaFX Dev, O=Oracle, C=US"/>
        <fxsignjar keystore="sign/test.keystore" alias="TestAlias" 
            storepass="xyz123" destDir="sign">
           <fileset file="jar/HelloWorld.jar"/>
        </fxsignjar>

    </target>
</project>
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Blog about Java technology documentation and news about Java releases.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today