Friday, July 12, 2002 03:19 PM
A jar file is an archive of classes and other resources as images, clips and so on.
Jars are generally used to store in a group all the classes belonging to a package or more packages of the same technology. (There are jars for XML, mail, jdbc managing and so on).
If you want to create your jar for storing all your classes, you must use the "jar" program included in the JDK.
jar cvf archive_name.jar *.class
This is the syntax to create a new jar (named archive_name.jar) and store in it all the classes in the current directory.
Once created, the jar is usually included in the CLASSPATH of the executing environment so all the classes are available.
A class with a main method included in a jar needs however the java interpreter for execution. It isn't a stand-alone executable.
jar tvf archive_name.jar
shows all the content of the jar "archive_name.jar"