Skip to main content Accessibility help
×
Hostname: page-component-76fb5796d-skm99 Total loading time: 0 Render date: 2024-04-29T07:26:18.279Z Has data issue: false hasContentIssue false

5 - Organizing Java files and other practicalities

Published online by Cambridge University Press:  08 January 2010

Clark S. Lindsey
Affiliation:
Space-H Services, Maryland
Johnny S. Tolliver
Affiliation:
Oak Ridge National Laboratory, Tennessee
Thomas Lindblad
Affiliation:
Royal Institute of Technology, Stockholm
Get access

Summary

Introduction

In this chapter we look first at several topics related to the organization of Java files. In fact, a scheme for organizing Java files and classes comes built into the language. When a class is used, the name of the class includes, either explicitly or implicitly (via the import directive), its location in a particular package. The Java package resembles the code libraries of other languages and provides a name space that successfully avoids name collisions. In practice, a large class library will contain many packages – the J2SE 1.4 class library contains over 100 separate packages – arranged in some sensible order. A very small, single-purpose library might reside entirely in just one package.

In some of the examples in previous chapters the code included the public modifier. We finally explain in this chapter exactly what that modifier does. It and the other access modifiers determine what classes, methods and fields can be used by methods in other classes and subclasses, in the same and in other packages.

For faster downloading, you can pack your Java packages, classes, images, audio files and other program resources into a single file called a JAR (Java Archive) file. JAR files use the ZIP format and compression system (a variation of Lempel-Ziv) to hold files and to maintain internally a hierarchical directory system like that on disk. We show how to create JAR files and how to extract files from them.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2005

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

References

Java Plug-in, http://java.sun.com/products/plugin/
Javadoc Tool documentation, http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/
Doug Lea, Draft Java Coding Standard, http://g.oswego.edu/dl/html/javaCodingStd.html
Lesson Formatting, The Java Tutorial at Sun Microsystems – http://java.sun.com/docs/books/tutorial/i18n/format/
Formatter class specification, Formatter class specification, http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html
Java 2 Platform, Standard Edition, API Specification, http://java.sun.com/j2se/1.5/docs/api/

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×