Documentation Contents
Java Platform, Standard Edition Tools Reference
Contents    Previous    Next

javapackager

Performs tasks related to packaging and signing Java and JavaFX applications.

Synopsis

javapackager command [options]

command

The task that should be performed.

options

One or more options for the command separated by spaces.

Commands

You can specify one of the following commands. After the command, specify the options for it.

-createbss

Converts CSS files into binary form.

-createjar

Produces a JAR archive according to other parameters.

-deploy

Assembles the application package for redistribution. By default, the deploy task generates the base application package, but it can also generate a self-contained application package if requested.

-makeall

Performs compilation, createjar, and deploy steps as one call, with most arguments predefined, and attempts to generate all applicable self-contained application packages. The source files must be located in a folder called src, and the resulting files (JAR, JNLP, HTML, and self-contained application packages) are put in a folder called dist. This command can only be configured in a minimal way and is as automated as possible.

-signjar

Signs JAR file(s) with a provided certificate.

Options for the createbss Command

-outdir dir

Name of the directory that will receive generated output files.

-srcdir dir

Base directory of the files to package.

-srcfiles files

List of files in the directory specified by the -srcdir option. If omitted, all files in the directory (which is a mandatory argument in this case) will be used. Files in the list must be separated by spaces.

Options for the createjar Command

-appclass app-class

Qualified name of the application class to be executed.

-argument arg

An unnamed argument to be inserted into the JNLP file as an <fx:argument> element.

-classpath files

List of dependent JAR file names.

-manifestAttrs manifest-attributes

List of names and values for additional manifest attributes. Syntax:

"name1=value1,name2=value2,name3=value3"
-nocss2bin

The packager will not convert CSS files to binary form before copying to JAR.

-outdir dir

Name of the directory that will receive generated output files.

-outfile filename

Name (without the extension) of the file that will be generated.

-paramfile file

A properties file with default named application parameters.

-preloader preloader-class

Qualified name of the JavaFX preloader class to be executed. Use this option only for JavaFX applications. Do not use for Java applications, including headless applications.

-srcdir dir

Base directory of the files to package.

-srcfiles files

List of files in the directory specified by the -srcdir option. If omitted, all files in the directory (which is a mandatory argument in this case) will be used. Files in the list must be separated by spaces.

Options for the deploy Command

-allpermissions

If present, the application will require all security permissions in the JNLP file.

-appclass app-class

Qualified name of the application class to be executed.

-argument arg

An unnamed argument to be inserted into an <fx:argument> element in the JNLP file.

-Bbundler-argument=value

Provides information to the bundler that is used to package a self-contained application. See Arguments for Self-Contained Application Bundlers for information on the arguments for each bundler.

-callbacks

Specifies user callback methods in generated HTML. The format is the following:

"name1:value1,name2:value2,..."
-description description

Description of the application.

-embedCertificates

If present, the certificates will be embedded in the JNLP file.

-embedjnlp

If present, the JNLP file will be embedded in the HTML document.

-height height

Height of the application.

-htmlparamfile file

Properties file with parameters for the resulting application when it is run in the browser.

-isExtension

If present, the srcfiles are treated as extensions.

-name name

Name of the application.

-native type

Generate self-contained application bundles (if possible). Use the -B option to provide arguments to the bundlers being used. If type is specified, then only a bundle of this type is created. If no type is specified, all is used.

The following values are valid for type:

  • all: Runs all of the installers for the platform on which it is running, and creates a disk image for the application. This value is used if type is not specified.

  • installer: Runs all of the installers for the platform on which it is running.

  • image: Creates a disk image for the application. On Windows, the image is the directory that gets installed.

  • exe: Generates a Windows .exe package.

  • msi: Generates a Windows Installer package.

-outdir dir

Name of the directory that will receive generated output files.

-outfile filename

Name (without the extension) of the file that will be generated.

-paramfile file

Properties file with default named application parameters.

-preloader preloader-class

Qualified name of the JavaFX preloader class to be executed. Use this option only for JavaFX applications. Do not use for Java applications, including headless applications.

-srcdir dir

Base directory of the files to package.

-srcfiles files

List of files in the directory specified by the -srcdir option. If omitted, all files in the directory (which is a mandatory argument in this case) will be used. Files in the list must be separated by spaces.

-templateId

Application ID of the application for template processing.

-templateInFilename

Name of the HTML template file. Placeholders are in the following form:

#XXXX.YYYY(APPID)#

Where APPID 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

    http://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.

-templateOutFilename

Name of the HTML file that will be generated from the template.

-title title

Title of the application.

-vendor vendor

Vendor of the application.

-width width

Width of the application.

-updatemode update-mode

Sets the update mode for the JNLP file.

Options for the makeall Command

-appclass app-class

Qualified name of the application class to be executed.

-classpath files

List of dependent JAR file names.

-height height

Height of the application.

-name name

Name of the application.

-preloader preloader-class

Qualified name of the JavaFX preloader class to be executed. Use this option only for JavaFX applications. Do not use for Java applications, including headless applications.

-width width

Width of the application.

Options for the signjar Command

-alias

Alias for the key.

-keyPass

Password for recovering the key.

-keyStore file

Keystore file name.

-outdir dir

Name of the directory that will receive generated output files.

-srcdir dir

Base directory of the files to be signed.

-srcfiles files

List of files in the directory specified by the -srcdir option. If omitted, all files in the directory (which is a mandatory argument in this case) will be used. Files in the list must be separated by spaces.

-storePass

Password to check integrity of the keystore or unlock the keystore

-storeType

Keystore type. The default value is "jks".

Arguments for Self-Contained Application Bundlers

The -B option for the -deploy command is used to specify arguments for the bundler that is used to create self-contained applications. Each type of bundler has its own set of arguments.

General Bundler Arguments

appVersion=version

Version of the application package. Some bundlers restrict the format of the version string.

classPath=path

Class path relative to the assembled application directory. The path is typically extracted from the JAR file manifest, and does not need to be set if you are using the other javapackager commands.

icon=path

Location of the default icon to be used for launchers and other assists. For Windows, the format must be .ico.

identifier=value

Default value that is used for other platform-specific values such as mac.CFBundleIdentifier. Reverse DNS order is recommended, for example, com.example.application.my-application.

jvmOptions=option

Option to be passed to the JVM when the application is run. Any option that is valid for the java command can be used. To pass more than one option, use multiple instances of the -B option, as shown in the following example:

-BjvmOptions=-Xmx128m -BjvmOptions=-Xms128m
jvmProperties=property=value

Java System Property to be passed to the VM when the application is run. Any property that is valid for the -D option of the java command can be used. Specify both the property name and the value for the property. To pass more than one property, use multiple instances of the -B option, as shown in the following example:

-BjvmProperties=apiUserName=example -BjvmProperties=apiKey=abcdef1234567890
mainJar=filename

Name of the JAR file that contains the main class for the application. The file name is typically extracted from the JAR file manifest, and does not need to be set if you are using the other javapackager commands.

preferencesID=node

Preferences node to examine to check for JVM options that the user can override. The node specified is passed to the application at run time as the option -Dapp.preferences.id. This argument is used with the userJVMOptions argument.

runtime=path

Location of the JRE or JDK to include in the package bundle. Provide a file path to the root folder of the JDK or JRE. To use the system default JRE, do not provide a path, as shown in the following example:

-Bruntime=
userJvmOptions=option=value

JVM options that users can override. Any option that is valid for the java command can be used. Specify both the option name and the value for the option. To pass more than one option, use multiple instances of the -B option, as shown in the following example:

-BuserJvmOptions=-Xmx=128m -BuserJvmOptions=-Xms=128m

Windows EXE Bundler Arguments

copyright=string

Copyright string for the application. The string must be a single line no longer than 100 characters. This argument is used in various exe and registry metadata.

licenseFile=path

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, for example, -BlicenseFile=COPYING.

menuHint=boolean

Flag that indicates if a shortcut is installed on the start menu or start screen. Set to true to install the shortcut. The default is true.

shortcutHint=boolean

Flag that indicates if a shortcut is placed on the desktop. Set to true to add a shortcut to the desktop. The default is false.

systemWide=boolean

Flag that indicates if the application is installed in Program Files or in the standard location in the users home directory. Set to true to install the application in Program Files. Set to false to install the application in the user's home directory. The default is false.

win.menuGroup=group

Menu group in which to install the application when menuHint is true. This argument is ignored when menuHint is false.

vendor=value

Corporation, organization, or individual providing the application. This argument is used in various exe and registry metadata.

Windows MSI Bundler Arguments

menuHint=boolean

Flag that indicates if a shortcut is installed on the start menu or start screen. Set to true to install the shortcut. The default is true.

shortcutHint=boolean

Flag that indicates if a shortcut is placed on the desktop. Set to true to add a shortcut to the desktop. The default is false.

systemWide=boolean

Flag that indicates if the application is installed in Program Files or in the standard location in the users home directory. Set to true to install the application in Program Files. Set to false to install the application in the user's home directory. The default is true.

win.menuGroup=group

Menu group in which to install the application when menuHint is true. This argument is ignored when menuHint is false.

vendor=value

Corporation, organization, or individual providing the application. This argument is used in various exe and registry metadata.

Deprecated Options

The following options are no longer used by the packaging tool and are ignored if present.

-runtimeversion version

Version of the required JavaFX Runtime. Deprecated.

-noembedlauncher

If present, the packager will not add the JavaFX launcher classes to the JAR file. Deprecated.

Notes

  • A -v option can be used with any task command to enable verbose output.

  • When the -srcdir option is allowed in a command, it can be used more than once. If the -srcfiles option is specified, the files named in the argument will be looked for in the location specified in the preceding srcdir option. If there is no -srcdir preceding -srcfiles, the directory from which the javapackager command is executed is used.

Examples

Example 1 - Using the -createjar Command
javapackager -createjar -appclass package.ClassName
  -srcdir classes -outdir out -outfile outjar -v

Packages the contents of the classes directory to outjar.jar, sets the application class to package.ClassName.

Example 2 - Using the -deploy Command
javapackager -deploy -outdir outdir -outfile outfile -width 34 -height 43 
  -name AppName -appclass package.ClassName -v -srcdir compiled

Generates outfile.jnlp and the corresponding outfile.html files in outdir for application AppName, which is started by package.ClassName and has dimensions of 34 by 43 pixels.

Example 3 - Using the -makeall Command
javapackager -makeall -appclass brickbreaker.Main -name BrickBreaker -width 600
-height 600

Does all the packaging work including compilation, createjar, and deploy.

Example 4 - Using the -signjar Command
javapackager -signJar --outdir dist -keyStore sampleKeystore.jks -storePass ****
-alias duke -keypass **** -srcdir dist

Signs all of the JAR files in the dist directory, attaches a certificate with the specified alias, keyStore and storePass, and puts the signed JAR files back into the dist directory.

Example 5 - Using the -deploy Command with Bundler Arguments
javapackager -deploy -native exe -BsystemWide=true -BjvmOptions=-Xmx128m 
    -BjvmOptions=-Xms128m -outdir packages -outfile BrickBreaker -srcdir dist 
    -srcfiles BrickBreaker.jar -appclass brickbreaker.Main -name BrickBreaker 
    -title "BrickBreaker demo"

Generates the native Windows EXE package for running the BrickBreaker application as a self- contained application.

Contents    Previous    Next

Oracle and/or its affiliates Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved.
Contact Us