jar (original) (raw)

To shorten or simplify the jar command, you can specify arguments in a separate text file and pass it to the jar command with the at sign (@) as a prefix. When the jar command encounters an argument beginning with the at sign, it expands the contents of that file into the argument list.

An argument file can include options and arguments of the jar command (except the -J options, because they are passed to the launcher, which does not support argument files). The arguments within a file can be separated by spaces or newline characters. File names within an argument file are relative to the current directory from which you run the jar command, not relative to the location of the argument file. Wild cards, such as the asterisk (*), that might otherwise be expanded by the operating system shell, are not expanded.

The following example, shows how to create a classes.list file with names of files from the current directory output by the find command:

find . -name '*.class' -print > classes.list

You can then execute the jar command and pass the classes.list file to it using the @arg-file syntax:

jar cf my.jar @classes.list

An argument file can be specified with a path, but any file names inside the argument file that have relative paths are relative to the current working directory of the jar command, not to the path passed in, for example:

jar @dir/classes.list