Javatpoint Logo
Javatpoint Logo

Apache Ant Jar

JAR is a group of Java classes and known as Java Archive file. In Ant, we can create Jar files by using <jar> element in build.xml file.

It is a task and implicitly use FileSet and supports it?s attributes. It also allows to various nested elements like <include>, <exclude>, <patternset> etc and contains attributes which are given below.

Apache Ant Jar Attributes

Attribute Description Required
destfile The JAR file to create. Yes
basedir The directory from which to jar the files. No
compress Store and compress data. No
filesonly It is used to store only file entries. No
includes A list of patterns of files that must be included while creating Jar. No
excludes A list of patterns of files that must be excluded while creating Jar. No
update Indicates whether to update Jar or not. No
duplicate behavior when a duplicate file is found. Valid values are add, preserve, and fail. No
level Non-default level at which file compression should be performed. No
useLanguageEncodingFlag Whether to set the language encoding flag if the encoding is UTF-8. No
createUnicodeExtraFields Whether to create Unicode extra fields to store the file names a second time inside the entry's metadata. No
fallbacktoUTF8 Whether to use UTF-8 and the language encoding flag instead of the specified encoding. No
flattenAttributes Whether to merge attributes occurring more than once in a section. No
zip64Mode When to use Zip64 extensions for entries. No

JAR Example

Jar all files in the ${build}/classes directory into a file called app.jar in the ${dist}/lib directory. <jar destfile="${dist}/lib/app.jar" basedir="${build}/classes"/>





Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA