Chapter 17. Packaging and Documenting Classes


17. Packaging and Documenting Classes

A Java application will typically consist of many classes, sometimes hundreds, or even thousands of classes. Because Java requires each public class to be defined in a separate file, you end up with at least as many files as you have classes. This can easily become unmanageable when it comes to working with your classes, finding files, or installing and distributing your application. Fortunately, this was considered when Java was created, and Sun has defined a standard packaging mechanism for placing related classes into packages. Packages in Java are a way of organizing classes according to functionality. The packaging mechanism also organizes Java source files into a known directory structure based on the package names used.

There is also a standard mechanism in Java for packaging Java classes into standard archive files. Applications can be executed directly from the archive file, or libraries can be distributed as an archive. The standard Java archive file is the JAR file, and these files end with a .jar extension. The JAR file uses the Zip archive protocol, and JAR files can be extracted using any tool that supports unzipping an archive. Sun also provides the jar tool for creating and expanding JAR archives. The jar tool is part of the standard JDK distribution. JAR stands for Java Archive.




JavaT Phrasebook. Essential Code and Commands
Java Phrasebook
ISBN: 0672329077
EAN: 2147483647
Year: 2004
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net