Uncompressed ZIP/JAR Files
It is better to deliver your classes in a ZIP or JAR file than to deliver them one class at a time over the network or load them individually from separate files in the filesystem. This packaged delivery provides some of the benefits of clustering [25] (see Section 14.1.2). The benefits gained from packaging class files come from reducing I/O overheads such as repeated file opening and closing, and possibly improving seek times.[26] Within the ZIP or JAR file, the classes should not be compressed unless network download time is a factor for the application. The best way to deliver local classes for performance reasons is in an uncompressed ZIP or JAR file. Coincidentally, that’s how they’re delivered with the JDK.
It is possible to further improve the classloading times by packing
the classes into the ZIP/JAR file in the order in which they are
loaded by the
application. You can
determine the loading order by running the application with the
-verbose
option, but note that this ordering is
fragile: slight changes in the application can easily alter the
loading order of classes. A further extension to this idea is to
include your own
classloader that opens the ZIP/JAR file itself and reads in all files sequentially, loading them into memory immediately. Perhaps the final version of this performance improvement route is to dispense with the ZIP/JAR filesystem: it is quicker to load the files if they are concatenated together in one big file, with a header ...
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.
Read now
Unlock full access