Exploring the Java Archive (JAR) Format
You've probably worked with plenty of JAR files. But how much do you know about them?
In this article, we will perform a study of JAR files. Along the way, I'll point out features that have been added to the JAR format throughout Java's evolution to address the needs of the programming language.
Some Background
The Java Archive (JAR) format consolidates multiple files into a single archive file, which contain Java classes and other auxiliary files (such as properties files). Under the hood, JAR files use the ZIP file format. Accordingly, when you use a JAR file, you inherit offerings of the ZIP format, including lossless data compression and archiving.
Archiving class files and compressing them allows you to distribute applications quickly in a network environment. Not only are the files smaller, but multiple connections do not have to be established for each constituent file; one HTTP transaction can be used, as opposed to one for each file in the archive.
No study of the world of the JAR is complete without examining the tool to make them: the Java Archive Tool. The Java Archive Tool, which ships with the Java Development Kit, can be invoked using the jar command.
As you will see, usage of the JAR tool is not rocket science. We'll cover the basics of using the JAR tool before delving a bit deeper into some more extended offerings of the tool later in this article.