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.

162Chapter 5The Sun Microsystems Java Software <str<strong>on</strong>g>Development</str<strong>on</strong>g> Kit5.11.1.2 Putting a Compiled <str<strong>on</strong>g>Applicati<strong>on</strong></str<strong>on</strong>g> in a JAR FileLet’s assume we are going to manually put a Java applicati<strong>on</strong> in a JAR file. Wewill want to specify the name of the class that c<strong>on</strong>tains the main() method ofthe applicati<strong>on</strong>. First off, you want the JAR’s directory hierarchy to begin atthe folder that c<strong>on</strong>tains the first node of each package’s name. Our sample applicati<strong>on</strong>here is in the package net.multitool.Payback, so we want ourpresent working directory to be the <strong>on</strong>e which c<strong>on</strong>tains the net subdirectory.Here’s a dump of the directory tree from that point after compilati<strong>on</strong> of oursample applicati<strong>on</strong>:$ find . -print../net./net/multitool./net/multitool/Payback./net/multitool/Payback/Account.class./net/multitool/Payback/Purchase.class./net/multitool/Payback/Cost.class./net/multitool/Payback/DebtAccount.class./net/multitool/Payback/Payback.class./net/multitool/Payback/SavingsAccount.class./net/multitool/util./net/multitool/util/SAM<strong>on</strong>ey.class./net/multitool/util/SAM<strong>on</strong>eyTest$1.class./net/multitool/util/SAM<strong>on</strong>eyTest$2.class./net/multitool/util/SAM<strong>on</strong>eyTest.class$We now want to specify which class c<strong>on</strong>tains the applicati<strong>on</strong>’s main()method. It happens to be the Payback class, so we create a file calledmanifest 28 with the following c<strong>on</strong>tents:$ cat manifestMain-Class: net.multitool.Payback.PaybackNext, we use the jar utility to create the JAR file:28. It can have any name. The key/value pairs from the file will be placed by the jar utility intothe standard manifest called META-INF/MANIFEST.MF no matter what name you give tothis file.

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

Saved successfully!

Ooh no, something went wrong!