Jar: Difference between revisions
Jump to navigation
Jump to search
Line 24: | Line 24: | ||
=Update an existing JAR File= | =Update an existing JAR File= | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
jar ufv ... | jar ufv <jar-file> ... | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 08:26, 11 November 2020
External
Internal
Overview
Create a JAR from Files Located in a Directory Different from the Current One
Use -C after the JAR name and use . instead of * if you want to include all from <directory-we-want-to-JAR-from>:
jar -C <directory-we-want-to-JAR-from> cfv <JAR-file-name> .
Example:
jar cfv ./target/A.ear -C ./target/ear-A-content .
Update an existing JAR File
jar ufv <jar-file> ...
Extract a Specific File from a JAR
jar xf .../source.jar META-INF/MANIFEST.MF
Do Not Create a Manifest File
jar cfM ...
Create a JAR with a Specific Manifest Content
jar cfm .../<jar-file-name>.jar .../<maifest-file> *
Executable JAR
Executable JAR in META-INF
Main-Class: some.class.Main
Executable JAR in Maven
Executable JAR in ant
<target name="jar" depends="compile"> <jar destfile="target/tdanalyzer.jar"> <zipfileset dir="./target/classes" includes="**/*.class"/> <manifest> <attribute name="Main-Class" value="com.novaordis.universus.tdanalyzer.Main"/> </manifest> </jar> </target>