Archiving Classes with Jar

jar cf project.jar *.class

The jar utility is included with the JDK, and is used to package groups of classes into a bundle. Using the jar tool, you can create, update, extract, list, and index a JAR file. In this phrase, all the classes contained in the current directory from which the jar command is run will be put into a JAR file with the name project.jar. The c option tells the jar utility to create a new archive file. The f option is always followed by a filename specifying the name of the JAR file to use.

Complete applications can be distributed as JAR files. Applications can also be executed out of a JAR file without having to first extract them. See the phrase “Running a Program from a JAR File” contained in ...

Get Java™ Phrasebook 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.