Working with JAR Files

A JAR file (Java ARchive) uses the same algorithm as a Zip utility does to compress numerous documents into one archive document. The benefit of a .jar file is that the developer can combine HTML, applets, class files, images, sounds, and everything else that makes up an application, and put them all into a JAR to facilitate easy distribution of the application. The jar tool is a Java application tool, regularly available with the SDK.

Note that you can add v to the command-line call options for verbose output, to indicate what is happening while your JAR is being created.

  1. Creating a New JARNavigate to the directory in which you want to create the JAR.

  2. Type the following at the command line:

    jar cf myJar *.class
    

Adding ...

Get Java Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.