Packaging Java software. What the problem is zAn executable program often consists of a very large...
-
Upload
elinor-phillips -
Category
Documents
-
view
213 -
download
0
Transcript of Packaging Java software. What the problem is zAn executable program often consists of a very large...
Packaging Java software
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
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
Creating a .zip file, I
To create a .zip file, use WinZip Classic
Creating a .zip file, II
The WinZip Classic interface is easy to figure out Create a new archive Add files to it
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
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
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
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
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
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
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">
Other options
InstallAnywhere is also widely used
InstallAnywhere Now! is the basic version
Now! is free
InstallShield Pro is widely used
"Industrial strength" $995
The End