Here's how to create an ant target to JAR up the contents of subdirectory bin (compiled Java class files). Similar things must happen to create a WAR file (ant target <war ... />).
01.
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
02.
<
project
name
=
"helloworld.makejar"
default
=
"makejar"
basedir
=
"."
>
03.
04.
<
target
name
=
"makejar"
description
=
"Create a JAR for the HelloWorld project"
>
05.
<
delete
file
=
"helloworld.jar"
/>
06.
07.
<
jar
jarfile
=
"helloworld.jar"
includes
=
"**/*.class"
basedir
=
"bin"
>
08.
<
manifest
>
09.
<
attribute
name
=
"Built-By"
value
=
"${user.name}"
/>
10.
<
attribute
name
=
"Main-Class"
value
=
"project.builder.example.HelloWorld"
/>
11.
<
attribute
name
=
"Specification-Title"
value
=
"Example that works"
/>
12.
<
attribute
name
=
"Specification-Version"
value
=
"1.0.0"
/>
13.
<
attribute
name
=
"Specification-Vendor"
value
=
"Example Organization"
/>
14.
<
attribute
name
=
"Implementation-Title"
value
=
"common"
/>
15.
<
attribute
name
=
"Implementation-Version"
value
=
"1.0.0 today"
/>
16.
<
attribute
name
=
"Implementation-Vendor"
value
=
"Acme Corp."
/>
17.
</
manifest
>
18.
</
jar
>
19.
</
target
>
20.
21.
<
javac
srcdir
=
"src"
destdir
=
"bin"
includeantruntime
=
"false"
/>
22.
</
project
>