1 / 11

Objectives: 1. Archiving and Packaging Java Code 2. The jar Program

Objectives: 1. Archiving and Packaging Java Code 2. The jar Program. JAR Files. JAR file archives provide packaging for Application, Applets, & JavaBeans Multiple classes can be packaged in JAR files JAR Files with HTML Manifest file JAR files use ZIP compression format.

yehuda
Download Presentation

Objectives: 1. Archiving and Packaging Java Code 2. The jar Program

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Objectives: 1. Archiving and Packaging Java Code 2. The jar Program JAR Files

  2. JAR file archives provide packaging for Application, Applets, & JavaBeans Multiple classes can be packaged in JAR files JAR Files with HTML Manifest file JAR files use ZIP compression format JAR Files

  3. Creates JAR files Extracts Contained Elements Lists JAR file contents Usage: jar {ctux} [vfm0M] [jar-file] [manifest-file] files The jar Program

  4. Only one of the following c: Create a new archive file t: List the table of contents for the archive file u: Update the contents of the archive or manifest x: Extract named files (or all) from the archive Other options can be combined or omitted v: Verbose output f: Specify [jar-file] m: Include information from [manifest-file] 0: Do not use compression M: Do not create a manifest file for the archive entries jar command line options

  5. Create an archive called Simulator.jar that contained the single class Machine.class jar cf Simulator.jar Machine.class List the table of contents of Simulator.jar using verbose output jar tvf Simulator.jar Extract all contents of Simulator.jar jar xvf Simulator.jar Examples of jar command

  6. Improve Applet download performance ARCHIVE Tag <APPLET ARCHIVE=“Simulator.jar” CODE=Stock.class WIDTH=350 HEIGHT=250> </APPLET> JAR Files & HTML

  7. Automatically created Named /META-INF/Manifest.mf Lists the entries in the archive First entry identifies manifest version Manifest-Version: 1.0 Created-By: 1.5.0 (Sun Microsystems Inc.) The Manifest

  8. Main section shown in previous slide Applies to the entire JAR file Subsequent sections must begin with Name: entry and describe individual elements contained in JAR file like JavaBeans, files, packages, and URLs. Name: Calculator.class lines describing this file Name: edu/weber/mypkg lines describing this package Manifest Contents

  9. Attribute/Value pairs Note Java-Bean attribute Name: StockBroker/Simulator/Stock.class Digest-Algorithms: MD5 SHA MD5-Digest: wuXrtYN-56Nn4rtDFewq=-tr SHA-Digest: fg67tKdkfR65-SRkdrslegvY-tyK Java-Bean: True Manifest Contents

  10. Manifest-Version: 1.0 Name: StockBroker/Simulator/Stock.class Java-Bean: True Name: StockBroker/Simulator/Helper.class Java-Bean: False Name: StockBroker/Simulator/Price.class Java-Bean: True Custom Manifest File Indicating Beans

  11. jar cfm Simulator.jar Simulator.mf StockBroker/Simulator/Stock.class StockBroker/Simulator/Helper.class StockBroker/Simulator/Price.class Creating the Archive File

More Related