what is jar archivesjar archives are zip archives


What is JAR archives?

JAR archives are ZIP archives along with a different extension. They contain a hierarchy of files and directories. In spirit a JAR file can take the place of a directory containing its contents. This has several uses involving the distribution of associated classes as a single file.

The JDK involve a jar program modeled after the Unix tar program in which will bundle up files and directories into a JAR archive. For instance, suppose your homework directory contains the file Trivia.class.

Now suppose in which Trivia is in the package edu.poly.utopia.eharold.games. Also suppose that the directory /home/users/eharold/homework/ contains (in various sub-directories) all the files and directories essential to run the program edu.poly.utopia.eharold.games.Trivia. You can pack up everyhting in the edu package into a JAR archive like this:

$ cd /home/users/eharold/homework
$ jar cvf eharold.jar edu
The edu directory and all its contents are recursively stored in the archive named eharold.jar. The name of the archive is not important, only its contents.

This archive might now be added to the class path like this, or in whatever fashion you normally add directories to the class path on your platform of choice:

$ setenv CLASSPATH $CLASSPATH:eharold.jar

The major thing to note here is in which the JAR file is now taking the place of an whole directory hierarchy.
In Java 1.2 you can also place it within the ext directory of your jre/lib directory.

Either way, all the classes in the archive will be added to the class path and will be easy to get to to your programs.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: what is jar archivesjar archives are zip archives
Reference No:- TGS0284865

Expected delivery within 24 Hours