13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.11 Bundling a Java Program: Put It in a JAR161JAR file and run java against it. With this simple setup, users need not evenknow they are using a Java applicati<strong>on</strong>—it runs like any other applicati<strong>on</strong>.5.11.1.1 The Manifest FileThe <strong>on</strong>ly way in which jar really differs from any other ZIP archive utility isin the automatic creati<strong>on</strong> and use of a manifest file, by default namedMETA-INF/MANIFEST in the archive. Even if you do not specify a manifest fileof your own, the jar utility creates <strong>on</strong>e for you. Let’s take a moment to look atwhat goes into the manifest.A manifest is basically a list of key/value pairs. The key comes at the startof a line and the value comes at the end of the line with a col<strong>on</strong> separating thetwo. Example 5.21 shows a sample manifest.Example 5.21 Manifest from the Payback sample applicati<strong>on</strong>Manifest-Versi<strong>on</strong>: 1.0Ant-Versi<strong>on</strong>: Apache Ant 1.5.3Created-By: 1.4.1_02-b06 (Sun Microsystems Inc.)Versi<strong>on</strong>: 1.0Main-Class: net.multitool.Payback.PaybackAll of these entries were produced automatically by ant or the jar utilityitself, except for Main-Class, which we specified (albeit with ant, as you willsee in Chapter 9). The manifest has certain values that are always filled in byjar, but two that you might comm<strong>on</strong>ly specify are• Main-Class, which allows users to run a Java applicati<strong>on</strong> by merely typingjava someJarFile.jar, without having to know the fully packagequalified name of the class that c<strong>on</strong>tains the applicati<strong>on</strong>’s main().• Class-Path, which allows you to specify what the classpath should bewhen the applicati<strong>on</strong> is run.There are keys specific to applets, to signed applicati<strong>on</strong>s, to beans, and soforth. We will address these as it becomes necessary. Full details can, of course,be found in the Sun’s documentati<strong>on</strong> for jar. 2727. http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/jar.html

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!