0% found this document useful (0 votes)
3 views3 pages

Jar CF Jarfilename Inputfiles: JAR (Java Archieve File) FILES: .Class

A JAR (Java Archive) file is a compressed file that bundles multiple .class files, images, and other resources for easy project management. It includes a manifest file that describes the archive's features and can be created, viewed, and extracted using specific jar commands. JAR files offer benefits such as security, decreased download time, compression, and packaging for extensions, among others.

Uploaded by

yopm34347
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Jar CF Jarfilename Inputfiles: JAR (Java Archieve File) FILES: .Class

A JAR (Java Archive) file is a compressed file that bundles multiple .class files, images, and other resources for easy project management. It includes a manifest file that describes the archive's features and can be created, viewed, and extracted using specific jar commands. JAR files offer benefits such as security, decreased download time, compression, and packaging for extensions, among others.

Uploaded by

yopm34347
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

JAR(Java Archieve File) FILES:

 A JAR file is a file that contains compressed


version of several .class files, audio files,images
or directories.
 It is useful to bundle up several file related to
project and use them easily.
 Typically a JAR file contains the class files and
auxiliary resources associated with applets and
applications.
HOW TO CREATE JAR FILE?
1.To create .jar files command:
jar cf jarfilename inputfiles

cf: create file


Example: Assume a package pack available in C:\
directory to convert it into a jar file with the name
pack.jar.

jar cf pack.jar pack

2.To view the contents of .jar files command:

jar tf jarfilename

tf: table view of file contents


For our example, the command to view is:

jar tf pack.jar
Now, the content of pack.jar are displayed as
META-INF/
META-INF/MANIFEST.MF
pack/
pack/Addition.class
 The first two entries represent that there is a manifest
file created and added to pack.jar file.
 The third entry represents the sub directory with the name
pack and the last represent the file names in the directory
pack.

Manifest File:
 Each JAR file contains a manifest file that
describe the features of the archive.
 Each JAR file have a manifest file by default.
 Default manifest file is named as MANIFEST.MF and
is present in the META-INF subdirectory of archive.
 Although the default manifest file contains just
two entries, but complex manifest files can have
way more.

3.To extract the files from .jar files command:

jar xf filename

xf: extract files


 Example: To extract the content of pack.jar files:
jar xf pack.jar

JAR file format provides many benefits:


1.Security:
 You can digitally sign the contents of a JAR file.
2.Decreased download time:
 If your applet is bundled in a JAR file, the
applet's class files and associated resources can
be downloaded to a browser in a single HTTP
transaction without the need for opening a new
connection for each file.
3.Compression
 The JAR format allows you to compress your files
for efficient storage.

4.Packaging for extensions


 The extensions framework provides a means by which
you can add functionality to the Java core
platform, and the JAR file format defines the
packaging for extensions. By using the JAR file
format, you can turn your software into extensions
as well.
5.Package Sealing:
 Packages stored in JAR files can be optionally
sealed so that the package can enforce version
consistency. Sealing a package within a JAR file
means that all classes defined in that package must
be found in the same JAR file.
6.Package Versioning:
 A JAR file can hold data about the files it
contains, such as vendor and version information.
7.Portability
 The mechanism for handling JAR files is a standard
part of the Java platform's core API.

You might also like