Skip to Main Content
Java I/O, 2nd Edition
book

Java I/O, 2nd Edition

by Elliotte Rusty Harold
May 2006
Beginner to intermediate content levelBeginner to intermediate
726 pages
19h 57m
English
O'Reilly Media, Inc.
Content preview from Java I/O, 2nd Edition

Chapter 11. JAR Archives

JAR archives are the standard means of packaging and distributing Java software. They are used by applets, servlets, standalone GUI applications, class libraries, JavaBeans, and more. The content in a JAR archive can be found by the class loader, regardless of the file’s exact location in the filesystem, as long as it is somewhere in the classpath. This makes JARs a very convenient place to put configuration data, preferences, lookup tables, localization strings, and other noncode resources that need to be distributed with an application. In particular, storing such resources in JAR archives enables you to read them using standard streams without:

  • Worrying that the user will have moved them. When the application is distributed as a single file rather than a collection of nested folders, it’s harder for one file to be accidentally moved, deleted, or edited.

  • Concerning yourself with the detailed filesystem conventions on the local platform. Even if the local system uses backslashes or colons as path separators or doesn’t even have a filesystem (as is often the case in J2ME environments), the JAR file always uses standard Unix file and path conventions.

JAR files also improve performance, especially in applications such as applets and Java Web Start-launched applications that download their code from a server. First of all, the content in the JAR archive is compressed. More importantly, it is faster for a web browser to download one JAR file than to download all ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java I/O

Java I/O

Elliotte Rusty Harold
Java NIO

Java NIO

Ron Hitchens

Publisher Resources

ISBN: 0596527500Errata PageSupplemental Content