JAR files, stand for java archive, a file format based on zip file format ,which is used to aggregate number of files to a single one. Also supports file compression,the basic use of jar files in application development is to pack the resources including classes ,images,files,sounds etc in to single one, to save space and reduce download time. The jar facility in included from Java 1.2 and above distributions. A JAR file is created by the command line jar option, or by the java.util.jar API . A JAR file is typically a zip file that contains a META-INF directory. which is optional. The jar files gives the following advantages

Security Aspects – A jar file can be digitally signed which helps users to verify the signature and grant program security permissions.

Decreased download time -since the jar is compressed it takes less download time than individual file.

Package Versioning – we can include vendor and version information.

Portability – since JRE can interpret jar it will operate on all platforms.

Extensions -JAR file format defines the packaging for extensions. You can turn your software into extensions with jar. This is done by adding following header in the manifest file
Class-Path: extension2.jar

The simple method to create and manipulate jar files are follows.

For creating JAR files – jar cf jar-file input-file(s)
For viewing the contents – jar tf jar-file
For extracting the contents – jar xf jarfile
For extracting specific files from JAR files- jar xf jar-file archived-file(s)

options
c – create new jar file with name jarfile.jar
u – update the existing jar file.
x – extract files and directories from jar file.
t -list the table of content from the jar file.
I – generate index information of jar file.
f – specifies the jar file to be created/updated/viewed etc.
v – the verbose output generated to std. Output .
0 – Store without zip compression.
M – do not create /delete if present a manifest file.

Executable jar File

An executable jar file is nothing but a self-sustained Java application program that is stored in a JAR file format, executable jar file can be executed directly by the JVM . They do not need to be extracted or set up a class path. In order make your jar file runnable , you need to generate a manifest file. A manifest is a text file with a”Main-Class” directive (use standard format in naming, like manifest.txt etc).
e.g Main-Class: MyMainClass
jar cvfm MyJarName.jar manifest.txt *.class
This line must end with a newline.

Package sealing

Package sealing is one the features of jar ,which enable the user to enforce the classes defined in the package to be reside with in the jar. This feature provide version consistency and security enforcement. This is done by specifying the manifest file with the following headers
Name: com/MyPackage/
Sealed: true

The JAR format will serve more than just archiving the files; it has many features which provide improved efficiency, security, and organization of applications specifically in java. Because these features are built into JVM which bound to the core platform,just by including the JVM, developers can use the power of the JAR file format to simplify and improve their development processes. The jar file is not just a simple archive instead it encapsulate deployment descriptors ,libraries ,plug ins etc.