OO Programming with Java


Packaging & jar (source)

  1. The various files from the application can be grouped together into an 'archive' file created with the jar tool:
javac chap2/*.java                # compilation
java -cp . chap2.Group            # run
jar cvf groups.jar chap2/*.class  # create archive
java -cp groups.jar chap2.Group   # run with archive
  1. It is possible to select a main executable:
jar cvfe groups.jar chap2.Group chap2/*.class
java -jar groups.jar

The last command is used to execute a jar file when clicked on it for instance.


12 - 14