Java Reference
In-Depth Information
Your source files should use the same conventions, but with a different initial
directory so that source files and class files are kept separate. In this way, you can
ship your class files and not your source files. As applied to the example, the class
files would be in classes\mycompany\java4cobol\messages, and the source files
(with the .java extension) in source\mycompany\java4cobol\messages.
C OMPRESSED P ACKAGES
Finally, the Java compiler and the Java runtime system can read compressed (or
zipped) files that might contain many classes. Think of these compressed files as the
contents of a directory (including perhaps several subdirectories) packaged into a
single file. Microsoft's standard for packaging compressed classes is their cab tech-
nology; other vendors use the jar file technology for this purpose. This discussion
focuses on the jar file convention, although many of the benefits and techniques
would apply equally to cab files.
You can add a jar file to your CLASSPATH like this:
java -cp c:\java4cobol.jar HelloWorld
In this, the Java runtime program would look in the jar file to find the class
HelloWorld . Jar files provide several benefits, including these:
Related classes can be organized and managed in a single archive. This simpli-
fies the administration of the classes.
A single request (for the jar file) can copy many classes from one system to an-
other. This is especially important in an Internet browser, where a single HTTP
request for the jar file will replace several individual HTTP requests (one for
each class in the package). The browser issues HTTP requests to copy files from
the Web server to the browser. Combining several requests into a single request
is a significant performance benefit.
The classes in the jar file are compressed (using the zip compression format).
This can improve download performance and reduces disk space requirements.
Individual classes can be digitally signed by their author and checked at run-
time for authenticity. Only the single file needs to be checked, instead of each
component in the file.
Search WWH ::




Custom Search