JAR (file Format) - Design

Design

A JAR file allows Java runtimes to efficiently deploy a set of classes and their associated resources. The elements in a JAR file can be compressed, which, together with the ability to download an entire application in a single request, makes downloading a JAR file much more convenient than separately downloading the many uncompressed files which would form a single Java Application. The package java.util.zip contains classes that read and write JAR files.

A JAR file has an optional manifest file located in the path META-INF/MANIFEST.MF. The entries in the manifest file determine how one can use the JAR file. For instance, a Classpath entry can be used to specify other JAR files for loading with the JAR. This entry consists of a list of absolute or relative paths to other JAR files. Although intended to simplify JAR use, in practice it turns out to be notoriously brittle, as it depends on all the relevant JARs being in the exact locations specified when the entry-point JAR was built. To change versions or locations of libraries, a new manifest is needed.

To extract the contents of a JAR file users can use any standard unzip software, or the jar command which comes with every Java Virtual Machine: "jar -xf foo.jar".

Developers can digitally sign JAR files. In that case, the signature information becomes part of the embedded manifest file. The JAR itself is not signed, but instead every file inside the archive is listed along with its checksum; it is these checksums that are signed. Multiple entities may sign the JAR file, changing the JAR file itself with each signing, although the signed files themselves remain valid. When the Java runtime loads signed JAR files, it can validate the signatures and refuse to load classes that do not match the signature. It can also support 'sealed' packages, in which the Classloader will only permit Java classes to be loaded into the same package if they are all signed by the same entities. This prevents malicious code from being inserted into an existing package, and so gaining access to package-scoped classes and data.

Developers can obfuscate JAR files so that a user of the JAR file doesn't get much information regarding the code it contains, or to reduce its size, which is useful in mobile phone application development.

Read more about this topic:  JAR (file Format)

Famous quotes containing the word design:

    Humility is often only the putting on of a submissiveness by which men hope to bring other people to submit to them; it is a more calculated sort of pride, which debases itself with a design of being exalted; and though this vice transform itself into a thousand several shapes, yet the disguise is never more effectual nor more capable of deceiving the world than when concealed under a form of humility.
    François, Duc De La Rochefoucauld (1613–1680)

    Teaching is the perpetual end and office of all things. Teaching, instruction is the main design that shines through the sky and earth.
    Ralph Waldo Emerson (1803–1882)

    With wonderful art he grinds into paint for his picture all his moods and experiences, so that all his forces may be brought to the encounter. Apparently writing without a particular design or responsibility, setting down his soliloquies from time to time, taking advantage of all his humors, when at length the hour comes to declare himself, he puts down in plain English, without quotation marks, what he, Thomas Carlyle, is ready to defend in the face of the world.
    Henry David Thoreau (1817–1862)