Читать книгу OCP Oracle Certified Professional Java SE 17 Developer Study Guide - Jeanne Boyarsky - Страница 84

Creating a JAR File

Оглавление

Some JARs are created by others, such as those downloaded from the Internet or created by a teammate. Alternatively, you can create a JAR file yourself. To do so, you use the jar command. The simplest commands create a jar containing the files in the current directory. You can use the short or long form for each option.

jar -cvf myNewFile.jar . jar --create --verbose --file myNewFile.jar .

Alternatively, you can specify a directory instead of using the current directory.

jar -cvf myNewFile.jar -C dir .

There is no long form of the -C option. Table 1.4 lists the options you need to use the jar command to create a JAR file. In Chapter 12, you see jar again for modules.

TABLE 1.4 Important jar options

Option Description
-c --create Creates a new JAR file
-v --verbose Prints details when working with JAR files
-f <fileName> --file <fileName> JAR filename
-C <directory> Directory containing files to be used to create the JAR
OCP Oracle Certified Professional Java SE 17 Developer Study Guide

Подняться наверх