Jar: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
=External= | |||
* http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html | |||
=Internal= | =Internal= | ||
* [[java#Subjects|Java]] | * [[java#Subjects|Java]] | ||
=Overview= | |||
=Create a JAR from Files Located in a Directory Different from the Current One= | =Create a JAR from Files Located in a Directory Different from the Current One= | ||
Line 15: | Line 21: | ||
<pre> | <pre> | ||
jar cfv ./target/A.ear -C ./target/ear-A-content . | jar cfv ./target/A.ear -C ./target/ear-A-content . | ||
</pre> | |||
=Executable JAR= | |||
==Executable JAR in META-INF== | |||
<pre> | |||
Main-Class: some.class.Main | |||
</pre> | |||
==Executable JAR in Maven== | |||
==Executable JAR in ant== | |||
<pre> | |||
<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> | |||
</pre> | </pre> |
Revision as of 00:26, 15 March 2017
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 .
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>