A file with .jar extension is a Java ARchive file that contains many different application related files as a single file. This file format was created to reduce the speed of loading a downloaded Java Applet in browser via HTTP transaction, by avoiding to create multiple HTTP connections. A single JAR file can contain Java class files (.class), images, and sounds. Individual items inside a JAR file can be digitally signed by the application developer to authenticate their origin. JAR files are regularly used to create functional APIs that contain specific functionality related to that API. JAR files can be opened with archiving applications such as WinZip, WinRAR, 7-ZIP, and Oracle Java Runtime.
JAR File Format
JAR files are based on the popular ZIP file format that archives its individual content files in a single file. JAR file format supports compressions, resulting in a smaller file size for downloading and hence further improves the download time. The JAR file specifications artilce by Oracle gives complete details about the internal specifications of JAR files.
The Manifest File
When a JAR file is created, a manifest file is automatically created inside it that contains the metadata information about the contents of the JAR file. This file shows the contents that are packaged inside the JAR file. A typical Manifest file looks as follow which shows the folders and classes included in the JAR file.
JAR files can also comprise of an application that can be executed by Java Virtual Machine (JVM) similar to any other application on Microsoft Windows Operating System. In this case, the JVM needs to know about the application’s entry point that is any class with a public static void main method. The manifest file identifies such a class with Main-Class header in the following format: