home
products
education
support
partners
company

introduction

get started

articles

manual

tutorials

reference docs

case studies

knowledge base

goodies

screenshots

demos

echoes

Carousel zone




home

forums

downloads

bugs

mailing list
XUI Zone - manual

number of ratings 0
average rating 0.00

30 Packaging and deployment

This chapter will describe the steps involved in packaging and deploying a Carousel application. It will cover topics such as running from the command line, from a website using Java webstart, creating native executables and installation wizards.

Package your project

For convenience, it can be useful to create a batch file which will package all of the resource and class files and install them into a single jar file. So, by creating the following batch file in the root of a Carousel project all of the project files can be merged into a single jar.

Code Sample 30-1 - Sample jar script

# Create the file with a mainfest file

c:\j2sdk1.4.2_03\bin\jar cvf bundle.jar META-INF/MANIFEST.MF

# navigate to the resources directory and jar it's contents.

# Repeat this for all resource files

cd resources

c:\j2sdk1.4.2_03\bin\jar uvf ../bundle.jar *.*

cd ..\pages

c:\j2sdk1.4.2_03\bin\jar uvf ../bundle.jar *.*

cd ..\images

c:\j2sdk1.4.2_03\bin\jar uvf ../bundle.jar *.*

cd ..\classes

c:\j2sdk1.4.2_03\bin\jar uvf ../bundle.jar *.*

# Extract the contents of the jars which need to be included

# in the application into a tmep directory and jar them.

cd ..\lib

rd temp

md temp

cd temp

########## STARTED EXTRACTING JARS ############

c:\j2sdk1.4.2_03\bin\jar xvf ../XuiCoreSwing.jar

c:\j2sdk1.4.2_03\bin\jar xvf ../XuiOptional.jar

########## FINISHED EXTRACTING JARS ###########

c:\j2sdk1.4.2_03\bin\jar uvf ../../bundle.jar *.*

cd..\..

The first line in this script references a file called META-INF/MANIFEST.MF which looks like...

Code Sample 30-2 - The manifest file

Manifest-Version: 1.0

Main-Class: net.xoetrope.swing.XApplet

This file simply tells the jar that the net.xoetrope.swing.XApplet class needs to be loaded when the jar file is run. Note that the startup file is not specified in which case the XApplet class looks for and uses the startup.properties file if it is present.

You should now be able to run the application simply by double-clicking the jar file.

Running a Carousel application from the command line

Again, it is easier to create a batch file to launch the application. So, by creating a file ' run.bat ' in the root of the Carousel project folder, the application can be launched using the jar which was created in the previous section

Code Sample 30-3 - Launch Carousel with the command line

java.exe -cp bundle.jar net.xoetrope.swing.XApplet startup.properties

The startup.properties parameter is not necessary if the startup file is called ' startup.properties '.

If you do not wish to bundle all of your jars into a single jar you may wish to create the following file to launch the application.

Code Sample 30-4 - Specify the jars separately

java -cp .;.\lib\XuiCoreSwing.jar;.\lib\XuiOptional.jar;.\lib\Carousel.jar;.\bundle.jar; net.xoetrope.swing.XApplet startup.properties

In this case you will want to modify the bundle.bat file so as to remove the commands which jar the contents of the dependancies. The following lines should be removed from the bundle.bat file.

Code Sample 30-5 - Lines to be remove from the bundle.bat file

# cd ..\lib

# rd temp

# md temp

# cd temp

########## STARTED EXTRACTING JARS ############

# c:\j2sdk1.4.2_03\bin\jar xvf ../XuiCoreSwing.jar

# c:\j2sdk1.4.2_03\bin\jar xvf ../XuiOptional.jar

########## FINISHED EXTRACTING JARS ###########

# c:\j2sdk1.4.2_03\bin\jar uvf ../../bundle.jar *.*

Running a Carousel application using Java Web Start

Java Web Start is used where applications need to be deployed over the internet but do not run within the confines of a web browser. The client machine which attempts to run the application must have a valid Java runtime installed

Java Web Start reads the contents of a JNLP file which resides on a webserver in order to initialise an application. Before the application can be used, however, the jar file which is to be used needs to be signed with a code signing digital certificate. This certificate will be registered to your company name and can be purchased from one of the following.

Code Sample 30-6 - Sources for code signing certificates

Company

URL

Verisign

http://www.verisign.com/products-services/security-services/code-signing/digital-ids-code-signing/

Thawte

http://www.thawte.com/codesign/

GlobalSign

http://www.globalsign.net/digital_certificate/objectsign/index.cfm

Using the certificate which is obtained from the signing authority the jar file can be signed using the JDK. The following batch file will create a new, signed, version of the bundle.jar file.

Code Sample 30-7 - Signing the jar file

jarsigner -keystore cert.keystore -signedjar bundleS.jar bundle.jar

The signed jar can now be deployed to a webserver along with a JNLP file. For the new bundleS.jar file the JNLP file might look like...

Code Sample 30-8 - A sample JNLP file

Carousel Application

My Company Ltd

Some application

Carousel Application

startup.properties

In this example the JNLP file can be invoked by referencing http://www.mydomain.com/demos/carousel.jnlp

The .jnlp extension needs to be included in the mime types for the webserver it is running on if not already done so. The method of doing this varies accross webservers so the documentation for the webserver should be referred to.

Running a Carousel application from a web page

Using the bundle.jar file from the first section in this chapter, a web page can be created which will start it as an applet. This assumes that the project was written using the AWT packages and not the swing packages.

Code Sample 30-9 - Applet tag for the applet

It is possible to start an application written with the Swing packages as an applet by using the object tag

Code Sample 30-10 - Starting a swing application from a browser

classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"

codebase="http://java.sun.com/products/plugin/1.1/jinstall-11-win32.cab#Version=1,3,0,0"

width=50 height=50>

Creating a setup for your Carousel application

There are a number of ways of deploying your Carousel application from custom written deployments to third pary installers. In this section, however, the installer which will be used is izPack, an open source installer which can be downloaded from http://www.izforge.com/izpack/

The version of izPack being used in this section is 3.6.1. For other versions or more advanced information please visit the izforge website.

Setup izPack by downloading the IzPack-install-3.6.1.jar file and double-clicking it to install. For these examples it is assumed that izPack is installed into c:\programmer\IzPack

For convenience it is easier to create an izPack directory under the Carousel project root directory. Within this directory the following izPack configuration xml file can be created.

Code Sample 30-11 - The izPack configuration file

Carousel Installation

1.0

http://www.mydomain.net/

The base files

The info section of the file contains some basic information about the application being deployed. The guiprefs section will specify the size of the installation application. The locale can be modified to handle multiple languages.

The panels section specifies the screens which will make up the installation application. If there is a licence file for the application it can be specified here otherwise the LicencePanel node can be removed. Similarly, the InfoPanel displays a readmed for the application you are installing and can be removed if not appropriate.

Now all that is left to do is to create the installation jar file. This is done by creating a batch file in the izPack directory as follows:

Code Sample 30-12 - Create the installation jar file

"c:\Programmer\izpack\bin\compile" install.xml -b . -o install.jar -k standard

When run, the batch file will create the install.jar file. When double-clicked this file will start the installation script.

This jar file will only run if the Java runtime is installed on the machine. It is possible to automate the installation of the Java runtime by downloading the izpack-launcher-1.1.zip from the izforge website. All that is required then is to copy the dist/launcher-Win32.exe and the src/launcher.ini files to the izPack directory. The launcher.ini file is then modified to reflect the name of the installation jar.

Code Sample 30-13 - The modified Launcher.ini file

# Global entries, can be overriden by specific ones.

jar = install.jar

download = http://www.java.com/

# Win32 specific entries

[win32]

jre = jre/setup.exe

The download key specifies the source from which the Java runtime can be obtained in the event that it cannot be found on the system

The jre key specifies the subdirectory which contains the Java runtime which has been distributed with the setup. This setup for the Java runtime would typically be included when a CD installation is being distributed.

comments


If you were logged in you could rate this article or add a comment.