What is Runnable JAR archives
You can run a program stored within the JAR archive that has a main() method like this:
$ java -cp eharold.jar MainClassName
You must use the fully package qualified name. For instance,
$ java -cp eharold.jar edu.poly.utopia.eharold.games.Trivia
The -cp flag adds the jar file to the class path.
In Java 1.2 you can add a Main-Class attribute to a JAR file's manifest so in which the person who runs the program does not requires to know the name of the name of the class with the main() method. This attribute has the subsequent form
Put this line into a file known as (for example) MyManifest.txt. Then use this command line to package the JAR:
$ jar cvmf MyManifest.txt eharold.jar edu
This will copy data from the file MyManifest.txt into the JAR's own manifest file, and add the directory edu to the archive.
To run the program packaged in the jar file eharold.jar you simply type:
$ java -jar eharold.jar
Java will look inside the JAR archive's manifest to search out which class's main() method it should run.