Jar: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 13: Line 13:
Use <tt>-C</tt> ''after'' the JAR name and use <tt>.</tt> instead of <tt>*</tt> if you want to include ''all'' from <tt><directory-we-want-to-JAR-from></tt>:
Use <tt>-C</tt> ''after'' the JAR name and use <tt>.</tt> instead of <tt>*</tt> if you want to include ''all'' from <tt><directory-we-want-to-JAR-from></tt>:


<pre>
jar -C <directory-we-want-to-JAR-from> cfv <JAR-file-name> .
jar -C <directory-we-want-to-JAR-from> cfv <JAR-file-name> .
</pre>


Example:
Example:


<pre>
jar cfv ./target/A.ear -C ./target/ear-A-content .
jar cfv ./target/A.ear -C ./target/ear-A-content .
 
</pre>
=Extract a Specific File from a JAR=


=Executable JAR=
=Executable JAR=

Revision as of 23:07, 5 June 2019

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 .

Extract a Specific File from a JAR

Executable JAR

Executable JAR in META-INF

Main-Class: some.class.Main

Executable JAR in Maven

Maven JAR Plugin - Declaring a Main Class

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>