JavaFX Ant tasks and the Java Packager tool are the recommended ways to package your applications.
This chapter contains the following topics:
See also the following two Ant Task Reference sections:
The ant-javafx.jar
file is required to use these tasks. It is located in the following locations:
In JDK 7 Update 6 or later, it is located in jdk_home/lib
In a standalone JavaFX installation, it is located in javafx-sdk-home/lib
There are two categories of Ant elements: JavaFX Ant tasks and Ant helper parameters.
JavaFX Ant Tasks
JavaFX Ant tasks perform the following tasks:
Creating JAR files that can be double-clicked
Creating an HTML page and deployment descriptor for Web Start applications or applications embedded in a web page
Digitally signing an application, when necessary
Converting CSS files to binary format
Assembling self-contained application packages
Elements are described in JavaFX Ant Task Reference.
Ant Helper Parameters
Ant helper parameters are used by the JavaFX Ant tasks. The helper parameters are described in JavaFX Ant Helper Parameter Reference.
To use the JavaFX Ant tasks in your Ant script, you must load their definitions. An example is shown in the build.xml
file in Example 3-1.
Notes about Example 3-1:
Ensure that you declare the fx: namespace, shown in bold in Example 3-1, because short names for some of JavaFX tasks are the same as those used for some system tasks.
The current directory (".") is added to the classpath to simplify customization using drop-in resources. See Customizing the Package Using Drop-In Resources.
After JavaFX Ant task definitions are loaded, the javafx.ant.version
property can be used to check the version of Ant tasks APIs. Use the following list for version numbers:
Version 1.0: shipped in the JavaFX 2.0 SDK
Version 1.1: shipped in the JavaFX 2.1 SDK
Version 1.2: shipped in the JavaFX 2.2 SDK and JDK 7 Update 6
Example 3-1 Load JavaFX Ant Task Definitions
<project name="JavaFXSample" default="default" basedir="."
xmlns:fx="javafx:com.sun.javafx.tools.ant">
<target name="default">
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
uri="javafx:com.sun.javafx.tools.ant"
classpath=".:${JAVA_HOME}/lib/ant-javafx.jar"/>
</target>
</project>
This section covers the following topics:
Follow these steps to deploy the JavaFX Hello World example as a JAR file with an Ant script:
Example 3-2 HelloWorld.java
import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class HelloWorld extends Application { @Override public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("Say 'Hello World'"); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { System.out.println("Hello World!"); } }); StackPane root = new StackPane(); root.getChildren().add(btn); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
Example 3-3 Ant Script to Deploy JavaFX Hello World Example
<?xml version="1.0" encoding="UTF-8" ?> <project name="JavaFX Hello World Example" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant"> <property name="JAVA_HOME" value="C:\\Java\\jdk-9"/> <property name="build.src.dir" value="src"/> <property name="build.classes.dir" value="classes"/> <property name="build.dist.dir" value="dist"/> <target name="default" depends="clean,compile"> <taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri="javafx:com.sun.javafx.tools.ant" classpath="${JAVA_HOME}/lib/ant-javafx.jar"/> <fx:application id="HelloWorldID" name="JavaFXHelloWorldApp" mainClass="HelloWorld"/> <fx:resources id="appRes"> <fx:fileset dir="${build.dist.dir}" includes="HelloWorld.jar"/> </fx:resources> <fx:jar destfile="${build.dist.dir}/HelloWorld.jar"> <fx:application refid="HelloWorldID"/> <fx:resources refid="appRes"/> <fileset dir="${build.classes.dir}"/> </fx:jar> <fx:deploy width="300" height="250" outdir="." embedJNLP="true" outfile="helloworld"> <fx:application refId="HelloWorldID"/> <fx:resources refid="appRes"/> <fx:info title="JavaFX Hello World Application" vendor="Oracle Corporation"/> </fx:deploy> </target> <target name="clean"> <mkdir dir="${build.classes.dir}"/> <mkdir dir="${build.dist.dir}"/> <delete> <fileset dir="${build.classes.dir}" includes="**/*"/> <fileset dir="${build.dist.dir}" includes="**/*"/> </delete> </target> <target name="compile" depends="clean"> <javac includeantruntime="false" srcdir="${build.src.dir}" destdir="${build.classes.dir}" fork="yes" executable="${JAVA_HOME}/bin/javac" source="9" debug="on"> </javac> </target> </project>
To deploy the JavaFX Hello World example as a self-contained application, add the attribute nativeBundles="all"
to the element <fx:deploy>
in the build.xml
script:
<fx:deploy width="300" height="250"
outdir="." embedJNLP="true"
outfile="helloworld"
nativeBundles="all">
Compile, build, and deploy the JavaFX Hello World example as described in the previous section. The Ant script creates all applicable self-contained application packages and stores them in the directory C:\example\bundles\JavaFXHelloWorldApp
. (The name JavaFXHelloWorldApp
is the value of the name
attribute of the <fx:application>
element.) If you are deploying the JavaFX Hello World example with Windows, for example, the Ant script creates an application named C:\example\bundles\JavaFXHelloWorldApp\JavaFXHelloWorldApp.exe
that you can run by double-clicking it in a file browser.
You can customize how your Ant script creates self-contained applications. See Self-Contained Application Packaging.
The JavaFX Ensemble8 sample application requires Apache Lucene. Example 3-4 shows how to deploy Ensemble8 as a self-contained application and include the Apache Lucene JAR files in it.
The following lines in the Ant script copy resources contained in the src
directory to the directory that contains the compiled Java class files. The resources are copied after the Ant script compiles the sample application:
<copy todir="${build.classes.dir}"> <fileset dir="src/app/resources"/> <fileset dir="src/generated/resources"/> <fileset dir="src/samples/resources"/> </copy>
The following lines from the Ant script include the Apache Lucerne JAR files (which are contained in the lib
directory):
<fx:resources id="appRes"> <fx:fileset dir="${build.dist.dir}" includes="ensemble8.jar"/> <fx:fileset dir="lib"/> <fx:fileset dir="${build.classes.dir}"/> </fx:resources> <fx:jar destfile="${build.dist.dir}/ensemble8.jar"> <fx:application refid="ensemble8"/> <fx:resources refid="appRes"/> </fx:jar>
Example 3-4 Ant Script to Deploy Ensemble8 Sample Application
<?xml version="1.0" encoding="UTF-8" ?> <project name="Ensemble8 JavaFX Demo Application" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant"> <property name="JAVA_HOME" value="C:\\Java\\jdk-9"/> <path id="CLASSPATH"> <pathelement ___location="lib/lucene-core-3.2.0.jar"/> <pathelement ___location="lib/lucene-grouping-3.2.0.jar"/> <pathelement path="classes"/> </path> <property name="build.src.dir" value="src"/> <property name="build.classes.dir" value="classes"/> <property name="build.dist.dir" value="dist"/> <target name="default" depends="clean,compile"> <taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri="javafx:com.sun.javafx.tools.ant" classpath="${JAVA_HOME}/lib/ant-javafx.jar"/> <fx:application id="ensemble8" name="Ensemble8" mainClass="ensemble.EnsembleApp"/> <fx:resources id="appRes"> <fx:fileset dir="${build.dist.dir}" includes="ensemble8.jar"/> <fx:fileset dir="lib"/> <fx:fileset dir="${build.classes.dir}"/> </fx:resources> <fx:jar destfile="${build.dist.dir}/ensemble8.jar"> <fx:application refid="ensemble8"/> <fx:resources refid="appRes"/> </fx:jar> <fx:deploy outdir="." embedJNLP="true" outfile="ensemble8" nativeBundles="all"> <fx:application refId="ensemble8"/> <fx:resources refid="appRes"/> <fx:info title="Ensemble8 JavaFX Demo Application" vendor="Oracle Corporation"/> </fx:deploy> </target> <target name="clean"> <mkdir dir="${build.classes.dir}"/> <mkdir dir="${build.dist.dir}"/> <delete> <fileset dir="${build.classes.dir}" includes="**/*"/> <fileset dir="${build.dist.dir}" includes="**/*"/> </delete> </target> <target name="compile" depends="clean"> <javac includeantruntime="false" srcdir="${build.src.dir}" destdir="${build.classes.dir}" fork="yes" executable="${JAVA_HOME}/bin/javac" source="9" debug="on" classpathref="CLASSPATH"> </javac> <!-- Copy resources to build.classes.dir --> <copy todir="${build.classes.dir}"> <fileset dir="src/app/resources"/> <fileset dir="src/generated/resources"/> <fileset dir="src/samples/resources"/> </copy> </target> </project>
You can override JVM options in your self-contained applications by specifying them in a preferences node, then setting the name of this node in the app.preferences.id
system property. The following example overrides the -Xms
and -Xmx
JVM options specified in <fx:jvmuserarg> elements. To verify that these options have been overridden, the application displays the initial and maximum sizes of the memory allocation pool (based on the values of the -Xms
and -Xmx
options).
Example 3-5 MemoryExamplePreferences.java
import java.util.prefs.Preferences; public class MemoryTestPreferences { private Preferences prefs; public void setPreferences() { // This will define a node in which the preferences can be stored prefs = Preferences.userRoot().node(System.getProperty("app.preferences.id")).node("JVMUserOptions"); // now set the values prefs.put("-Xmx", "2048m"); prefs.put("-Xms", "2048m"); } public static void main(String[] args) { MemoryTestPreferences myPrefs = new MemoryTestPreferences(); myPrefs.setPreferences(); } }
Example 3-6 MemoryExample.java
import javafx.application.Application; import javafx.collections.FXCollections; import javafx.geometry.HPos; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.scene.control.TextField; import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.GridPane; import javafx.scene.layout.Priority; import javafx.scene.layout.Region; import javafx.stage.Stage; import java.lang.management.ManagementFactory; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; public class MemoryTest extends Application { @Override public void start(Stage primaryStage) { String startMemory = Long.toString(Runtime.getRuntime().totalMemory()); String maxMemory = Long.toString(Runtime.getRuntime().maxMemory()); System.out.println("Start memory: " + startMemory); System.out.println("Max memory: " + maxMemory); final Label startMemoryLabel = new Label("Start memory: "); TextField startMemoryTextField = new TextField(startMemory); startMemoryTextField.setPromptText(startMemory); Label maxMemoryLabel = new Label("Max memory: "); final TextField maxMemoryTextField = new TextField(maxMemory); maxMemoryTextField.setPromptText(maxMemory); Label jvmArgumentsLabel = new Label("JVM Arguments"); ListView<String> jvmArguments = new ListView<>(FXCollections.observableArrayList(ManagementFactory.getRuntimeMXBean().getInputArguments())); jvmArguments.setPrefSize(450, 150); Button btn = new Button(); btn.setText("Update Preferences"); btn.setOnAction(event -> { Preferences prefs = Preferences.userRoot().node(System.getProperty("app.preferences.id")).node("JVMUserOptions"); String start = startMemoryTextField.getText(); if (start == null || start.isEmpty()) { prefs.remove("-Xms"); } else { prefs.put("-Xms", start); } String max = maxMemoryTextField.getText(); if (max == null || max.isEmpty()) { prefs.remove("-Xmx"); } else { prefs.put("-Xmx", max); } try { prefs.flush(); } catch (BackingStoreException e) { e.printStackTrace(); } }); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); grid.getColumnConstraints().setAll( new ColumnConstraints(Region.USE_PREF_SIZE, Region.USE_COMPUTED_SIZE, Region.USE_PREF_SIZE, Priority.NEVER, HPos.RIGHT, false), new ColumnConstraints(Region.USE_PREF_SIZE, Region.USE_COMPUTED_SIZE, Integer.MAX_VALUE, Priority.ALWAYS, HPos.LEFT, true) ); grid.addRow(0, startMemoryLabel, startMemoryTextField); grid.addRow(1, maxMemoryLabel, maxMemoryTextField); grid.addRow(2, jvmArgumentsLabel, jvmArguments); grid.add(btn, 1, 3); grid.setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE); Scene scene = new Scene(grid); primaryStage.setTitle("Memory test"); primaryStage.sizeToScene(); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
Example 3-7 Ant Script for Memory Test Example
<?xml version="1.0" encoding="UTF-8" ?> <project name="JavaFX Hello World Example" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant"> <property environment="env"/> <property name="env.JAVA_HOME" value="C:\\Java\\jdk-9"/> <property name="build.src.dir" value="src"/> <property name="build.classes.dir" value="classes"/> <property name="build.dist.dir" value="dist"/> <target name="default" depends="clean,compile"> <taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri="javafx:com.sun.javafx.tools.ant" classpath="${env.JAVA_HOME}/lib/ant-javafx.jar"/> <fx:application id="MemoryTestAppID" name="JavaFXMemoryTestApp" mainClass="MemoryTest"/> <fx:resources id="appRes"> <fx:fileset dir="${build.dist.dir}" includes="MemoryTest.jar"/> </fx:resources> <fx:jar destfile="${build.dist.dir}/MemoryTest.jar"> <fx:application refid="MemoryTestAppID"/> <fx:resources refid="appRes"/> <fileset dir="${build.classes.dir}"/> </fx:jar> <fx:deploy width="300" height="250" outdir="." embedJNLP="true" outfile="memorytest" nativeBundles="image"> <fx:platform> <fx:jvmuserarg name="-Xms" value="31m"/> <fx:jvmuserarg name="-Xmx" value="64m"/> </fx:platform> <fx:application refId="MemoryTestAppID"/> <fx:resources refid="appRes"/> <fx:info title="JavaFX Hello World Application" vendor="Oracle Corporation"/> </fx:deploy> </target> <target name="clean"> <mkdir dir="${build.classes.dir}"/> <mkdir dir="${build.dist.dir}"/> <delete> <fileset dir="${build.classes.dir}" includes="**/*"/> <fileset dir="${build.dist.dir}" includes="**/*"/> </delete> </target> <target name="compile" depends="clean"> <javac includeantruntime="false" srcdir="${build.src.dir}" destdir="${build.classes.dir}" fork="yes" executable="${env.JAVA_HOME}/bin/javac" source="9" debug="on"> </javac> <!-- Set preferences --> <java fork="true" jvm="${env.JAVA_HOME}\bin\java" classname="MemoryTestPreferences" classpath="${build.classes.dir}"> <sysproperty key="app.preferences.id" value="MemoryTestAppID"/> </java> </target> <target name="jar" depends="compile"> <jar destfile="dist/MemoryTest.jar" basedir="classes"/> </target> </project>
The UserJvmOptionsService
API offers an alternative method for setting JVM options for self-contained applications. This API can be called from the application to get the current settings and to update the settings for the next time that the application is started.
The following items comprise the main JavaFX Ant tasks:
Converts CSS files to binary format for faster processing.
Assembles the application package for redistribution. By default, the deploy task will generate the base application package, but it can also generate self-contained application packages if requested.
Creates one or more application JAR files.
Provides the application with a digital signature.
Note:
The<fx:signjar>
task for the Java Packager tool is deprecated in JDK 9 in preparation for removal in a future release. It also does not work with multi-release JAR files. Use the standard Ant signjar
task instead.Items are in alphabetical order.
Description
Converts a set of CSS files into binary form (BSS).
Parent Elements
None.
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Name of the directory in which output files are generated. |
String |
Yes |
Parameters Accepted as Nested Elements
Description
Generates a package for both web deployment and standalone applications. The package includes a set of JAR files, a JNLP file, and an HTML file.
Parent Elements
None.
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
If present, this value will be used for Javascript/HMTL code instead of width/height. Affects only embedded deployment mode. Use it if you want to specify a relative dimension for an embedded application. |
String |
No |
|
Same description as for |
String |
No |
|
If true, embed the JNLP descriptor into the web page. Reduces number of network connections to be made on startup and helps to improve startup time. |
Boolean |
No Default is |
|
Treat the files named in |
Boolean |
No Default is |
|
Height of the application scene, for embedding applications into a web page. |
String |
Yes |
|
If set to |
Boolean |
No Default is |
|
Values:
Value |
String |
No Default is |
|
If the value is |
Boolean |
Default is |
|
Name of the directory in which output files are generated. |
String |
Yes |
|
Prefix of the output files, without the extension. |
String |
Yes |
|
Placeholder in the web page where the application will be embedded. This is expected to be JavaScript DOM object. |
String |
Yes Either reference or ID of placeholder is required. |
|
Used with callbacks. The ID of the placeholder in the web page where application will be embedded. The JavaScript function |
String |
Yes Either the reference or the ID of the placeholder is required. |
|
Used for self-contained applications to request that the bundler sign the bundle that is generated. This attribute is ignored by bundlers that do not support signing. At the time of the 8u40 release of the JDK, only macOS bundlers support signing. |
Boolean |
Default depends on the bundler used. |
|
Indicates the preferences for when checks for application updates are performed for embedded and Web Start applications. A value of A value of |
String |
No Default is |
|
Width of the application scene, for embedding applications into a web page. |
String |
Yes |
Parameters Accepted as Nested Elements
<fx:deploy> Task Usage Examples
This is a simple example of an <fx:deploy>
Ant task. It generates an HTML file and JNLP file into the web-dist directory and uses Fish
as the prefix for the generated files.
<fx:deploy width="600" height="400" outdir="web-dist" outfile="Fish" offlineAllowed="false"> <fx:info title="Sample application"/> <fx:application refid="myapp"/> <fx:resources refid="myresources"/> </fx:deploy>
The following Ant task creates a distributable package for a simple application with a preloader. Details about the application and its resources are defined in the <fx:application>
and <resource>
elements in the task.
Note that the ___location of the output package is defined by the outdir
attribute of the <fx:deploy>
task. New files are generated using the name
prefix specified in the outfile
attribute. As a result of execution of this task, the following files are created in the web-dist folder:
preloader.jar
helloworld.jar
App.jnlp
App.html
Note:
By default, the deployment package uses auxiliary files from java.com to support web deployment. This is the preferred way, because it enables the application to always use the best way to deploy on the web. However, if you want to test your application in a closed network then you can include these files into your application package. To do this, pass includeDT="true"
as an attribute in the <fx:deploy>
Ant task.
<fx:deploy width="600" height="400" outdir="web-dist" outfile="App"> <fx:info title="Sample application"/> <fx:application name="SampleApp" mainClass="testapp.MainApp" preloaderClass="testpreloader.Preloader"> <fx:param name="testVariable" value="10"/> </fx:application> <fx:resources> <fx:fileset requiredFor="preloader" dir="dist"> <include name="preloader.jar"/> </fx:fileset> <fx:fileset dir="dist"> <include name="helloworld.jar"/> </fx:fileset> </fx:resources> </fx:deploy>
This example creates a package for a self-contained application that contains a secondary launcher that can be used to start the application in a memory-constrained environment. The main launcher does not set JVM options. The secondary launcher passes an option to limit the amount of memory used.
<fx:deploy outdir="../samples/test/ant" nativeBundles="image"> <fx:application name="Secondary Launcher Sample" mainClass="hello.Test"/> <fx:resources> <fx:fileset dir="../samples/test/resources" includes="mainApp.jar"/> </fx:resources> <fx:info title="Secondary Launcher Test"/> <fx:secondaryLauncher mainClass="hello.Test" name="Standard Launch"/> <fx:secondaryLauncher name="Memory Constrained"> <fx:jvmarg="-xmx64m"/> </fx:secondaryLauncher> </fx:deploy>
<fx:deploy outdir="${bundles.dir}" outfile="MinesweeperFX" nativeBundles="all" verbose="true" <fx:runtime strip-native-commands="false"> <fx:add-modules value="java.base"/> <fx:add-modules value="jdk.packager.services,javafx.controls"/> <fx:limit-modules value="java.sql"/> <fx:limit-modules value="jdk.packager.services,javafx.controls"/> <fx:module-path value="${java.home}/../images/jmods"/> <fx:module-path value="${build.dir/modules"/> </fx:runtime> <fx:application id="MinesweeperFX" name="MinesweeperFX" module="fx.minesweeper" mainClass="minesweeper.Minesweeper" version="1.0"> </fx:application> <fx:secondaryLauncher name="Test2" module="hello.world" mainClass="com.greetings.HelloWorld"> </fx:secondaryLauncher> </fx:deploy>
Description
Packages an application into a JAR file. The set of files to be included is defined by nested <fx:fileset>
parameters. The <fx:jar>
task also embeds a JAR manifest into the JAR file.
In addition to creating a JAR archive, this task also:
Embeds the JavaFX launcher for JavaFX applications, which detects the presence of JavaFX Runtime, sets up the environment, and executes the application.
Creates a manifest in the JAR file.
The resulting JAR file supports launching by double-clicking.
Parent Elements
None.
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Base ___location for all relative URLs specified in |
String |
No |
|
Path to output JAR file (___location and name) |
String |
Yes |
Parameters Accepted as Nested Elements
<fx:jar> Usage Examples
See Example 3-3 and the following example.
This example shows how to use the <fx:jar>
Ant task to create the main application JAR file for a simple application without a custom preloader. The resulting JAR file performs the following two actions:
Starts test.MyApplication with all resources needed on the classpath when launched as java -jar application.jar
or by double-clicking the JAR file.
Automatically detects the ___location of JavaFX Runtime and prompts the user to install it if it is not available, or reports if the platform is not supported.
<!-- Expect definition of JavaFX ant tasks is already imported --> <fx:jar destfile="dist/application.jar"> <!-- Details about application --> <fx:application name="Sample JavaFX application" mainClass="test.MyApplication"/> <!-- Define what auxilary resources are needed --> <fx:resources> <fx:fileset dir="dist" includes="lib/*.jar"/> </fx:resources> <!-- What to include into result jar file? Everything in the build tree --> <fileset dir="build/classes"/> <!-- Customize jar manifest (optional) --> <manifest> <attribute name="Implementation-Vendor" value="Samples Team"/> <attribute name="Implementation-Version" value="1.0"/> </manifest> </fx:jar>
Description
Note:
The<fx:signjar>
task for the Java Packager tool is deprecated in JDK 9 in preparation for removal in a future release. It also does not work with multi-release JAR files. Use the standard Ant signjar
task instead.Digitally signs an application JAR file with a certificate.
Signs the JAR file as BLOB. In other words, instead of every entry being signed separately, the JAR file is signed as a single binary object.
Parent Elements
None.
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
The alias for the key |
String |
Yes |
|
Location of output file |
String |
Yes |
|
Password for the private key |
String |
Yes |
|
Keystore file name |
File |
Yes |
|
The JAR file to sign* |
String |
No Either this attribute or a nested |
|
Password to check integrity of the keystore or unlock the keystore |
String |
Yes |
|
Keystore type |
String |
No Default is |
|
Enable verbose output. |
Boolean |
No Default is |
*Note that:
<fx:signjar jar="path/to/jar/folder/jarname" .../>
is simply a convenience syntax for the following:
<fx:signjar ...> <fileset dir="path/to/jar/folder" file="jarname"/> </fx:signjar>
Parameters Accepted as Nested Elements
Helper parameters are types that are used by the JavaFX tasks described in JavaFX Ant Task Reference. This reference page contains the following elements:
Items are in alphabetical order.
Description
List of modules to add to the runtime generated for a self-contained application. All modules can be added in a single instance of <fx:add-modules>
using a comma-separated list, or an instance of <fx:add-modules>
can be used for each module to add.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
One or more modules to include in the runtime. For more than one, separate the modules with a comma. |
String |
No |
Parameters Accepted as Nested Elements
None.
<fx:add-modules> Usage Examples
jdk.packager.services
and javafx.controls
in the runtimeUse a single instance of <fx:add-modules>
:
<fx:runtime> <fx:add-modules value="jdk.packager.services,javafx.controls"/> </fx:runtime>
Use an instance of <fx:add-modules>
for each module:
<fx:runtime> <fx:add-modules value="jdk.packager.services"/> <fx:add-modules value="javafx.controls"/> </fx:runtime>
Description
Basic application descriptor. It defines the main components and default set of parameters of the application.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Indicates if the application is installed as a daemon or a service. |
Boolean |
No Default value is |
|
Application ID that can be used to get a JavaScript reference to the application in HTML. The same ID can be used to refer to an application object in the Ant task (using |
String |
No |
|
Qualified name of the main application class, which should extend |
String |
Yes |
|
Main module of a modular application. This is used as the default root module when constructing the application's initial module graph. |
String |
Yes, if bundling a modular application. Invalid if the application is not modular. |
|
Short name of the application. For self-contained applications, also defines the name of the output package. |
String |
No Default value is derived from the main application class. |
|
Qualified name of the preloader class, which should extend |
String |
No Default is the preloader that is shipped with the JavaFX Runtime. |
|
-- |
Reference |
No |
|
Indicates your preference for the application to use a specific UI toolkit. Possible values:
|
String |
No Default value is |
|
Version of the application being packaged. |
String |
No Default value is 1.0. |
* If refid
is used, then none of the other parameters can be specified.
Parameters Accepted as Nested Elements
<fx:application> Usage Examples
<fx:application id="HelloWorldID" name="JavaFXHelloWorldApp" mainClass="HelloWorld"/>
<fx:application id="MinesweeperFX" name="MinesweeperFX" module="fx.minesweeper" mainClass="minesweeper.Minesweeper"/>
See Example 3-3 for an example of a complete ant script.
Description
An unnamed argument that is inserted in the <fx:argument>
element in the deployment descriptor. Multiple arguments are added to the list of arguments in the same order as they are listed in the Ant script.
Parent Elements
Parameters
None.
Parameters Accepted as Nested Elements
None.
<fx:argument> Usage Examples
<fx:application name="Sample app" mainClass="test.MyApplication"> <!-- unnamed arguments --> <fx:argument>Something</fx:argument> <!-- value with spaces that are generated at build time --> <fx:argument>JRE version: ${java.version}</fx:argument> <!-- example of value using a special character --> <fx:argument>true & false</fx:argument> </fx:application>
Description
Associates file extensions or MIME types with a self-contained application. Multiple instances of this element are supported.
Parent Element
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Description of the types of tiles that are associated with the application. If no description is provided, then application-name |
String |
No |
|
One or more file extensions to associate with the application. Separate values with a space, for example, |
String |
Depends on the bundlerFoot 1 |
|
MIME type of the files to associate with the application. Wild card symbols are not allowed. Only one value is allowed on Windows, multiple values separated by a space can be provided for Linux or macOS. |
String |
Depends on the bundlerFoot 2 |
|
Name of the file that contains the icon for files associated with this application. For Windows the icon format must be |
String |
No |
Footnote 1
Required on Windows. Either extension
or mimetype
must be provided on macOS.
Footnote 2
Required on Linux. Either extension
or mimetype
must be provided on macOS.
Parameters Accepted as Nested Elements
None.
<fx:association> Usage Example
This example associates a self-contained application on Windows with files that have the file extension .aaa
or .bbb
. and provides a description and icon.
<fx:info title="Association example"> <fx:association extension="aaa bbb" description="MyApp Data Files" icon="MyApp.ico"> </fx:association> </fx:info>
Description
Specifies an argument for the bundler that is used to create self-contained applications. Each type of bundler has its own set of arguments.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Name of bundler argument |
String |
Yes |
|
Value of bundler argument |
String |
Yes |
Arguments for Self-Contained Application Bundlers
Each type of bundler (macOS, Linux, and Windows) has its own set of arguments.
General Bundler Arguments
Directory in which to look for bundler-specific drop-in resources. For example, on macOS, to look in the current directory for the Info.plist
file, use the following:
<fx:bundleArgument arg="dropinResourcesRoot" value="."/>
The file is then found in the current directory: package/macosx/Info.plist
.
ID of a <fx:preferences> element to check for JVM options that the user can override.
macOS Application Bundler Arguments
The path to the default icon to use for launchers and other assists. The file format is .icns
.
Prefix that is applied to the signed binary when binaries that lack property list files (plists, which use the extension .plist
) or existing signatures are found inside the bundles.
Category for the application. The category must be in the list of categories found on the Apple Developer website.
Value stored in the info.plist
file for CFBundleIdentifier
. This value must be globally unique and contain only letters, numbers, dots, and dashes. Reverse DNS order is recommended, for example, com.example.application.my-application
.
Name of the application as it appears on the Mac Menu Bar. A name of less than 16 characters is recommended. The default is the name
attribute of the <fx:application> element.
Version number for the application, used internally. The value must be at least one integer and no more than three integers separated by periods (.) for example, 1.3 or 2.0.1. The value can be different than the value for the version
attribute of the <fx:application>
element. If the version
attribute is specified with a valid value and the mac.CFBundleVersion
argument is not specified, then the value for the version
attribute is used. If neither value is specified, 100 is used as the version number.
Name of the signing key used for Developer ID or Gatekeeper signing. If you imported a standard key from the Apple Developer Website, then that key is used by default. If no key can be identified, then the application is not signed.
macOS DMG (Disk Image) Bundler Arguments
Location of the End User License Agreement (EULA) to be presented or recorded by the bundler. The path is relative to the packaged application resources.
Version number for the application, used internally. The value must be at least one integer and no more than three integers separated by periods (.) for example, 1.3 or 2.0.1. The value can be different than the value for the version
attribute of the <fx:application>
element. If the version
attribute is specified with a valid value and the mac.CFBundleVersion
argument is not specified, then the value for the version
attribute is used. If neither value is specified, 100 is used as the version number.
Flag that indicates if DMG customization steps that depend on executing AppleScript code are skipped. Set to true
to skip the steps. When set to true
, the disk window does not have a background image, and the icons are not moved into place. If the systemWide
argument is also set to true
, then a symbolic link to the root Applications folder is added to the DMG file. If the systemWide
argument is set to false
, then only the application is added to the DMG file, no link to the desktop is added.
macOS PKG Bundler Arguments
Location of the End User License Agreement (EULA) to be presented or recorded by the bundler. The path is relative to the packaged application resources.
Version number for the application, used internally. The value must be at least one integer and no more than three integers separated by periods (.) for example, 1.3 or 2.0.1. The value can be different than the value for the version
attribute of the <fx:application>
element. If the version
attribute is specified with a valid value and the mac.CFBundleVersion
argument is not specified, then the value for the version
attribute is used. If neither value is specified, 100 is used as the version number.
Name of the signing key used for Developer ID or Gatekeeper signing. If you imported a standard key from the Apple Developer Website, then that key is used by default. If no key can be identified, then the application is not signed.
Mac App Store Bundler Arguments
Location of the file that contains the entitlements that the application operates under. The file must be in the format specified by Apple. The path to the file can be specified in absolute terms, or relative to your Ant file. If no entitlements are specified, then the application operates in a sandbox that is stricter than the typical applet sandbox, and access to network sockets and all files is prevented.
Version number for the application, used internally. The value must be at least one integer and no more than three integers separated by periods (.) for example, 1.3 or 2.0.1. The value can be different than the value for the version
attribute of the <fx:application>
element. If the version
attribute is specified with a valid value and the mac.CFBundleVersion
argument is not specified, then the value for the version
attribute is used. If neither value is specified, 100 is used as the version number. If this version is an upgrade for an existing application, the value must be greater than the previous version number.
Name of the application signing key for the Mac App Store. If you imported a standard key from the Apple Developer Website, then that key is used by default. If no key can be identified, then the application is not signed.
Name of the installer signing key for the Mac App Store. If you imported a standard key from the Apple Developer Website, then that key is used by default. If no key can be identified, then the application is not signed.
Linux Bundler Arguments
Windows EXE and MSI Bundler Arguments
The path of the default icon to use for launchers and other assists. The file format is .ico
.
Location of the End User License Agreement (EULA) to be presented or recorded by the bundler. The path is relative to the packaged application resources.
Menu group in which to install the application when the menu
attribute of the <fx:preferences> element is true
. This argument is ignored when menu
is false
.
<fx:bundleArgument> Usage Example
The following example specifies that the generated Windows Installer Package (MSI file) create a Start Menu shortcut in a menu group named Sample Applications. Note that you must specify that the bundler create an MSI file with the nativeBundles
attribute of the <fx:deploy> element.
<fx:deploy outdir="." outfile="helloworld" nativeBundles="msi"> <fx:platform basedir="${JAVA_HOME}"/> <fx:application refId="HelloWorldID"/> <fx:resources refid="appRes"/> <fx:info title="Hello World Example" vendor="Oracle Corporation"/> <fx:bundleArgument arg="win.menuGroup" value="Sample Applications"/> </fx:deploy>
Description
Defines a JavaScript callback that can be used to customize user experience.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Name of the event for callback. |
String |
Yes |
|
-- |
Reference |
No |
* If refid
is used, then none of the other parameters can be specified.
Parameters Accepted as Nested Elements
<TEXT>
<fx:callback> Usage Examples
In this example, a callback is used to create an HTML splash screen for an application embedded in a web page. When the event onGetSplash
is triggered, the JavaScript function customGetSplash
is executed.
<fx:callbacks> <fx:callback name="onGetSplash">customGetSplash</fx:callback> </fx:callbacks>
In this example, the callback is defined with JavaScript code in the <fx:callback>
element itself.
<fx:callbacks> <fx:callback name="onLoadHandler"> function () {perfLog(0, "onLoad called");} </fx:callback> </fx:callbacks>
<fx:callbacks> <fx:callback name="onJavascriptReady">callAppFunction</fx:callback> <fx:callback name="onGetSplash">function(id) {}</fx:callback> </fx:callbacks>
Description
Collection of JavaScript callbacks to be used to customize the user experience.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
-- |
Reference |
No |
* If refid
is used, then none of the other parameters can be specified.
Parameters Accepted as Nested Elements
<fx:callbacks> Usage Examples
See the examples for <fx:callback>.
Description
Extension of the standard Ant FileSet
type, which provides the means to specify optional meta information about a selected set of files. This includes:
Type of resource (see the type
attribute)
Operating system and architecture for which this resource is applicable
When this resource is needed, which helps to optimize loading order
Depending on type, the resource might not be used by the enclosing task.
A fileset of type "jar"
is expected to contain a set of JAR files to be added to the classpath.
Resource of type "native"
is expected to be a JAR file with a set of native libraries. In most of cases, it makes sense to set the operating system and architecture for this resource too.
Resources of type "jnlp"
are expected to contain JNLP files defining external JNLP extensions.
Filesets of type "license"
can contain arbitrary files, but additional restrictions can be applied when they are actually used (for example, on Mac it has to be a plain text file, and on Windows it needs to be RTF).
Filesets of type "data"
can contain arbitrary files.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
(used only when |
Specifies the architecture for which these resources should be considered. |
String |
No Default is |
|
Specifies the root directory that contains the files used in the task. |
String |
Yes |
|
Specifies files in the |
String |
No |
|
Specifies files in the |
String |
No |
(used only when |
Specifies the operating systems for which these resources should be considered. |
String |
No Default is |
(used only when |
Defines when resources are needed (affects loading priority). Supported values are:
|
String |
No Default is |
(used only when |
Type of the resources in the set. Supported values are:
|
String |
No Default is to guess based on extension. |
* If refid
is used, then none of the other parameters can be specified.
Parameters Accepted as Nested Elements
None (except standard Ant elements).
Description
Parameter to be passed to the embedded or Web Start application from the HTML page. The value of the parameter can be calculated at runtime using JavaScript.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Defines how to interpret the value for the values that are passed—as string literal (true) or JavaScript variable (false). |
Boolean |
No Default is true, meaning value is treated as string literal. |
|
Name of the parameter to be passed to the embedded or Web Start application from the HTML page. |
String |
Yes |
|
Value of the parameter. Could also be the name of a JavaScript variable whose value is expected to be passed as parameter. For JavaScript variables, ensure |
String |
Yes |
Parameters Accepted as Nested Elements
None
<fx:htmlParam> Task Usage Examples
<fx:application name="Sample app" mainClass="test.MyApplication"> <!-- Parameters passed from HTML page. Only applicable for embeddeded and Web Start applications and unused when run in a standalone and self-contained context. --> <!-- Parameter with name 'fixedParam', whose value is string '(new Date()).getTime()' --> <htmlParam name="fixedParam" value="(new Date()).getTime()"/> <!-- Parameter with name 'dynamicParam', whose value will be the timestamp of the moment when the application is added to the web page (value will be assigned the result of execution of JavaScript code) --> <htmlParam name="dynamicParam" escape="false" value="(new Date()).getTime()"/> </fx:application>
Description
Passes an icon to the <fx:deploy>
task, other than a splash screen image.
The icon specified in this element is used for Web Start and desktop applications.
Note that in JavaFX 2.2, only icons of type default
are used for self-contained applications. For details on how to customize the icon for self-contained applications, see Customizing the Package Using Drop-In Resources.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Color depth of the image in bits-per-pixel. Common values are 8, 16, and 24. |
String |
No |
|
Location of image. For self-contained applications, the supported graphic formats depend on the operating system:
Note that if you specify your own icon for a self-contained application, the values of the attributes For Web Start applications, the supported graphic formats are |
String |
Yes |
|
Image height in pixels |
String |
No |
|
Icon type. Supported values are:
For Web Start applications, this attribute corresponds to the For desktop applications, if this attribute is not specified or set as |
String |
No Default value is |
|
Image width in pixels |
String |
No |
Parameters Accepted as Nested Elements
None.
Description
Application description for users. These details are shown in the system dialog boxes, if they need to be shown.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Application category. Creates a link to an application in a specified category. Semantics of the value depends on the format of the package. For example:
|
String |
No |
|
Short copyright statement |
String |
No |
|
A short statement describing the application. |
String |
No |
|
License type (for example, GPL). As of JavaFX 2.2, this attribute is used only for Linux bundles. |
String |
No |
|
Title of the application |
String |
Yes |
|
Provider of the application |
String |
Yes |
Parameters Accepted as Nested Elements
Description
The JVM argument to be set in the JVM, where the application is executed. Can be used multiple times. Note that you do not need to additionally escape values if they contain space characters.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Value of JVM argument. |
String |
Yes |
Parameters Accepted as Nested Elements
None.
<fx:jvmarg> Usage Examples
See Example 2, "<fx:platform> Parameter to Specify JVM Options".
Description
The user overridable JVM argument to be set in the JVM, where the application is executed. Can be used multiple times. Note that you do not need to additionally escape values if they contain space characters.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Value of JVM argument. |
String |
Yes |
Parameters Accepted as Nested Elements
None.
<fx:jvmuserarg> Usage Examples
See Example 2, "<fx:platform> Parameter to Specify JVM Options".
Description
Limit the set of observable modules to those in the transitive closure of the list provided plus the main module, if any, plus any further modules specified in the <fx:add-modules>
element.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Comma-separated list of modules used to limit the universe of observable modules. |
String |
No |
Parameters Accepted as Nested Elements
None.
Description
Path to the application modules to include in the generated runtime.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
List of module locations. On Linux and macOS, use a colon (:) to separate paths. On Windows, use a semicolon (;). |
String |
No |
Parameters Accepted as Nested Elements
None.
Description
Parameter to be passed to the application (embedded into application package).
This tag has no impact on standalone applications, including self-contained applications.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Name of parameter |
String |
Yes |
|
Value of parameter |
String |
Yes |
Parameters Accepted as Nested Elements
None.
<fx:param> Task Usage Examples
<fx:application name="Sample app" mainClass="test.MyApplication"> <!-- parameter with name 'simpleParam' and fixed string value--> <param name="simpleParam" value="something"/> <!-- parameter with name 'complexParam' with value generated at build time --> <param name="complexParam" value="Compiled by ${java.version}"/> <!-- parameter with name 'novalueParam' and no value --> <param name="novalueParam"/> </fx:application>
Description
Definition of security permissions needed by application. By default, the application runs in the sandbox. Requesting elevated permissions requires signing the application JAR files.
This option has no impact on standalone applications, including self-contained applications.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
If set to false, the application runs in the sandbox. |
Boolean |
No Default is false. |
Parameters Accepted as Nested Elements
None.
Description
Defines application platform requirements.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
-- |
Reference |
No |
|
Minimum version of JRE required by the application. |
String |
No Default is any JRE supporting JavaFX. |
* If refid
is used, then none of the other parameters can be specified.
Parameters Accepted as Nested Elements
<fx:platform> Usage Examples
In this example, the application needs JRE version 9.0 or later.
<fx:platform j2se="9.0"/>
In this example, the application needs JRE version 9.0 or later and needs to run in a JVM launched with "-Xmx400 -verbose:jni -Dpurpose="sample value"
.
<fx:platform j2se="9.0"> <fx:jvmarg value="-Xmx400m"/> <fx:jvmarg value="-verbose:jni"/> <property name="purpose" value="sample value"/> </fx:platform>
In this example, -Xmx768m is passed as a default value for heap size. The user can override this value in a user configuration file.
<fx:platform> <fx:jvmuserarg name="-Xmx" value="768m" /> </fx:platform>
Description
Deployment preferences for the application. Preferences can be expressed but may not necessarily be satisfied, for example in the following cases:
The packager may ignore a preference if it is not supported for a particular execution mode.
JRE may ignore it if it is not supported.
The user may reject a request, for example if he is prompted whether a desktop shortcut can be created.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Install For self-contained applications, This value is ignored if the packager does not support different types of install packages for the requested package format. |
Boolean |
No For Web Start and embedded applications, default is For self-contained applications, default value is different for various package formats. |
|
If |
Boolean |
No Default is |
|
If |
Boolean |
No Default is |
|
-- |
Reference |
No |
|
If |
Boolean |
No Default is |
* If refid
is used, then none of the other parameters can be specified.
Parameters Accepted as Nested Elements
None.
<fx:preferences> Usage Examples
This example shows a request to create a desktop shortcut.
<fx:preferences id="p1" shortcut="true"/>
This example does the following:
It requests creation of a web deployment descriptor that will add the application to the Applications Menu and mark it as installed (in other words, the application will be listed in Add/Remove programs.)
If self-contained bundles are created, then they will be installed system-wide and will create an application entry in the Applications menu.
<fx:preferences shortcut="false" install="true" menu="true"/>
This example uses a reference to the <fx:preferences> parameter in Example 1, "<fx:preferences> Parameter to Add a Desktop Shortcut" to create the shortcut.
<fx:resource refid="p1"/>
Description
Optional element and can be used multiple times. Java property to be set in the JVM where the application is executed.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Name of property to be set. |
String |
Yes |
|
Value of property to be set. |
String |
Yes |
Parameters Accepted as Nested Elements
None.
Description
The collection of resources used by the application. Defined as a set of JavaFX FileSet filters. Could be reused using id
or refid
.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
ID that can be referred from another element with a refid attribute. |
String |
No |
|
-- |
Reference |
No |
* If refid
is used, then none of the other parameters can be specified.
Parameters Accepted as Nested Elements
<fx:resources> Usage Examples
In this example, both <fx:resources>
elements define the collection, consisting of s.jar
in the dist
directory. The first <fx:resources>
element uses an id
attribute, and the second <fx:resources>
element refers to the first with the refid
attribute.
<fx:resources id="aaa"> <fx:fileset dir="dist" includes="s.jar"/> </fx:resources> <fx:resources refid="aaa"/>
If you mix signed and unsigned JAR files, use an additional <fx:deploy> Ant task to generate an extension descriptor for each JAR file, and refer to the extension descriptors by treating them as resources in the main file, as shown in this example.
<!-- Prepare extension -->
<fx:deploy extension="true"
outdir="dist" outfile="other">
...
<fx:deploy>
<!-- Use it in the main descriptor -->
<fx:deploy outdir="web-dist" ...>
...
<fx:resources>
<fx:fileset dir="dist" includes="other.jnlp"/>
...
</fx:resources>
<fx:deploy>
Additional examples are available in Self-Contained Application Packaging.
Description
Runtime generated for your self-contained application. The jlink
tool is used to generate a runtime that contains only the packages that the application needs to run, and optionally, command-line tools such as java.exe
.
The Java Packager for JDK 9 generates a JDK 9 runtime image. To package a JDK 8 or JDK 7 JRE with your application, use the JDK 8 Java Packager.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
If set to |
Boolean |
No Default is true. |
Parameters Accepted as Nested Elements
<fx:runtime> Usage Examples
<fx:runtime strip-native-commands="false"/>
jdk.packager.services
and javafx.controls
in the runtime<fx:runtime> <fx:add-modules value="jdk.packager.services,javafx.controls"/> </fx:runtime>
jdk.packager.services
and provide the ___location of application modules<fx:runtime> <fx:add-modules value="jdk.packager.services"/> <fx:module-path value="${java.home}/../images/jmods"/> <fx:module-path value="${build.dir}/modules"/> </fx:runtime>
Description
Identifies a secondary entry point for a self-contained application and the main module for a modular application. This parameter is ignored for standalone applications, applications embedded in a web page, or applications launched from a browser.
This parameter is valid only for Windows and Linux applications.
Parent Elements
Parameters
Attribute | Description | Type | Required |
---|---|---|---|
|
Brief description of the application. |
String |
No |
|
Path to the icon file for the application. |
String |
No |
|
Qualified name of the main application class. |
String |
No |
|
Flag that indicates if the application is added to the Start menu. Either the |
Boolean |
No Default is |
|
Main module of a modular application. This is used as the default root module when constructing the application's initial module graph. |
String |
Yes, if bundling a modular application. Invalid if the application is not modular |
|
Name of the launcher that is used to start the application. |
String |
Yes |
|
Flag that indicates if a shortcut to the application is added to the desktop. Either the |
Boolean |
No Default is |
|
Title of the application. |
String |
No |
|
Name of the vendor that provided the application. |
String |
No |
|
Version of the application. |
String |
No |
Parameters Accepted as Nested Elements
<fx:bundleArgument>, only the icon
argument is valid when used with <fx:secondaryLauncher>
Description
Passes the ___location of the image to be used as a splash screen. Currently custom splash images can only be passed to Web Start applications, and use of this parameter has no impact on standalone applications or applications embedded into web pages.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Location of image. Supported graphic formats are JPEG, GIF, and PNG. |
String |
Yes |
|
Deployment mode. Supported values are:
|
String |
No Default value is |
Parameters Accepted as Nested Elements
None.
Description
Template to preprocess. A template is an HTML file that contains markers to be replaced with the JavaScript or HTML snippets that are required for web deployment. Using templates enables you to deploy your application directly into your own web pages. This simplifies the development process, especially when the application is tightly integrated with the page, for example when the web page uses JavaScript to communicate to the application.
Template markers have one of the following forms:
#
XXX#
#
XXX(
id)#
id is the identifier of an application and XXX is one of following:
DT.SCRIPT.___URL
Location of dtjava.js
in the Deployment Toolkit. By default, the ___location is
https://java.com/js/dtjava.js
.
DT.SCRIPT.CODE
Script element to include dtjava.js
of the Deployment Toolkit.
DT.EMBED.CODE.DYNAMIC
Code to embed the application into a given placeholder. It is expected that the code will be wrapped in the function()
method.
DT.EMBED.CODE.ONLOAD
All the code needed to embed the application into a web page using the onload
hook (except inclusion of dtjava.js
).
DT.LAUNCH.CODE
Code needed to launch the application. It is expected that the code will be wrapped in the function()
method.
A page with different applications can be processed multiple times, one per application. To avoid confusion, markers must use application IDs with an alphanumeric string and no spaces.
If the input and output files are the same then the template is processed in place.
Parent Elements
Parameters
Attribute | Description | Type | Required? |
---|---|---|---|
|
Input template file. |
File |
Yes |
|
Output file (after preprocessing). |
File |
No Default is the same as the input file. |
Parameters Accepted as Nested Elements
None
<fx:template> Usage Examples
This example shows a <fx:template>
parameter in which both input and output files are specified.
<fx:template file="App_template.html" tofile="App.html"/>
<fx:deploy placeholderId="ZZZ" width="600" height="400" outdir="dist-web" outfile="App1"> <fx:application id="myApp" name="Demo" mainClass="fish.FishApplication"/> <fx:template file="src/templates/EmbedApp_template.html" tofile="dist-web/EmbedApp.html"/> <fx:resources> <fx:fileset requiredFor="startup" dir="dist" includes="*.jar"/> </fx:resources> </fx:deploy>