Packaging Java software. What the problem is zAn executable program often consists of a very large...

14
Packaging Java software

Transcript of Packaging Java software. What the problem is zAn executable program often consists of a very large...

Page 1: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

Packaging Java software

Page 2: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

What the problem is

An executable program often consists of a very large number of files

It's a nuisance to manage lots of filesWe like to "package" files into a single file

for transportation and distributionWe will explore several different

packaging techniquesDifferent techniques are suitable for

different situations and kinds of programs

Page 3: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

Zip files

Zip files are convenient single archive files compressed to save space understood on all platforms

Most Windows users have probably used WinZip to unpack downloaded files

Fewer people have used WinZip to create zip files

Page 4: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

Creating a .zip file, I

To create a .zip file, use WinZip Classic

Page 5: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

Creating a .zip file, II

The WinZip Classic interface is easy to figure out Create a new archive Add files to it

Page 6: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

jar files

A jar (Java archive) file is like a zip file jar files were designed for Java, but can be

used for any kind of filesThe jar program is modeled after the UNIX

tar program and works very much like it tar originally stood for tape archive

jar files are particularly important for Applets An <applet> tag can request a jar archive

Page 7: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

Applets

Here's how an Applet gets loaded: First, the browser requests the .html page

containing the Applet The <applet code="MyApplet.class" ...> tag causes

the browser to request the file MyApplet.class The browser's Java VM looks at this file and makes requests for other .class files that may be needed

The applet starts and requests image and sound files

All this two-way communication takes timeApplets load faster if they make fewer requests

Page 8: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

Too many files

A complete Java Applet may consist of many .class files many .gif and/or .jpg files possibly some .avi or .mp3 files other file types may be included

My most complex "animation" applet uses: One .html file Four .class files Fifty .jpg files

Page 9: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

Creating a jar file

Example command: jar cvf arch.jar *.class cvf is a list of options

c -- create a jar filev -- verbose; tell what you do as you do itf -- use this jar file (almost always needed!)

arch.jar is the name of the file that is createdYou don't need the .jar extension, but it's a

good idea *.class says to include all class files

You can list additional files at the end

Page 10: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

Unpacking a jar file

Example command: jar xvf arch.jar cvf is a list of options

x -- extract from a jar filev -- verbose; tell what you do as you do itf -- use this jar file (almost always needed!)

arch.jar is the name of the file that is unpacked You will also get a "manifest" file that may

contain information about the jar fileMost of the time you can ignore the

manifest file

Page 11: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

Examining a jar file

Example command: jar tvf arch.jar cvf is a list of options

t -- tell what is in the jar filev -- verbose; tell what you do as you do itf -- use this jar file (almost always needed!)

arch.jar is the name of the file that is examined

Page 12: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

Using a jar file in an Applet

An applet must be used from an HTML pageThe Applet tag has three required

parameters: code = the name of the main class file height =, width = the size of the applet

To use a jar file, we need a fourth parameter: archive = name of the jar file

Example: <applet height="400" width="500"

code="TestEngine.class" archive="lispquiz.jar">

Page 13: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

Other options

InstallAnywhere is also widely used

InstallAnywhere Now! is the basic version

Now! is free

InstallShield Pro is widely used

"Industrial strength" $995

Page 14: Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.

The End