Thursday Oct 03, 2013

Signing a JNLP File

There are several advantages to signing a JNLP file. It will:

  • Ensure that others cannot change the content in your JNLP file. For example, by adding a random library, or changing application information.
  • Allow the use of arbitrary Java Virtual Machine (JVM) options and Java system properties in your application.
  • Prevent others from referencing your JAR file directly in their HTML browser applets.

To create a signed JNLP file you don't sign the JNLP file itself, but you include the JNLP file inside the directory structure before the JAR file is created and then signed. The JNLP file must be named APPLICATION.JNLP and is included in the JNLP-INF subdirectory. The JAR file is then created and signed in the usual manner. When a web start application is started, the JNLP file used must be identical to the JNLP file in the signed JAR in order for the application to run.

Note that you cannot use the APPLET tag to run an applet if JAR file contains a signed JNLP file.

The Signing and Verifying JAR Files lesson in the Java Tutorial explains how to sign a JAR file.

Monday Sep 23, 2013

JavaOne 2013: Deploying Java Applications Securely

Monday at JavaOne, Andy Herrick, Mark Howe, and David DeHaven talked about best practices for making Java applets and Java Web Start applications more secure in the Deploying Java Applications Securely conference. Andy, David, and Thomas Ng will also be hosting a BOF session on Tuesday, Java Deployment Security, Features, and Best Practices.

For additional information on secure deployments, see Guidelines for Securing Rich Internet Applications in the Java Tutorials. The Deploying an Applet and Deploying a Java Web Start Application lessons summarize the deployment steps, including security recommendations such as using manifest attributes and signing the JAR file.

The Deployment Rule Set feature for enterprise environments is described in Deployment Rule Set in the Java RIA Development and Deployment guide. This guide also provides a flow chart of how deployment works in Rich Internet Application Deployment Process.

Friday Aug 05, 2011

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>

Thursday Feb 18, 2010

Getting Java Applets to Work on Mac OS

Are you having trouble viewing some Java applets on a Mac? Got next generation Java Plug-in?[Read More]

Wednesday Nov 25, 2009

Java Applets Quiz

Do you enjoy quizzes? Take a minute to answer this quiz about Java applets.[Read More]

Tuesday Nov 24, 2009

Getting Applets To Talk To Each Other

Do you have more than one applet on a web page? Do you want the applets to share water cooler gossip? Ahem..ahem.. On a more serious note, do you want one applet to invoke methods or set variables of another applet? [Read More]

Tuesday Sep 22, 2009

Java Tutorial Update

We have just pushed an updated version of the Java Tutorial to the web. This update features:

Please let us know what you think!

- Sharon Zakhour

Thursday Apr 02, 2009

Deployment Toolkit 101

The Deployment Toolkit is a set of JavaScript functions that can help developers easily deploy rich internet applications. [Read More]

Tuesday Mar 31, 2009

Deploying An Applet In Under 10 Minutes

Want to learn how to quickly deploy a Java applet?[Read More]
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