Considering Deployment


Most likely your customer doesn't expect to have to run an IDE just to use your program.

Adding Jar targets to the build file

One simple way that we could deploy java applications is to distribute them as jar files.
The following targets, when suitably modified for your project, can be added to your
build file. One creates a jar file which doesn't include the tests and should be runnable
on most systems. The other actually runs the jar file.


    <target name="archive" depends="compile" description="Creates a distribution jar file">
        <jar casesensitive="false" destfile="${dist.dir}/stateExample.jar">
            <fileset dir="${build.dir}/classes">
                <include name="**/*.class" />
                <exclude name="**/*Tester.class" />
            </fileset>
            <fileset dir=".">
                <include name="images/*" />
                <include name="sounds/*" />
            </fileset>
            <manifest>
                <attribute name="Main-Class" value="stateExample.StateApp" />
            </manifest>
        </jar>
    </target>

    <target name="runJar" depends="archive" description="Run the jarred Application">
        <java failonerror="true" fork="true" jar="${dist.dir}/stateExample.jar" />
    </target>


435F07