Q:

Deploy JavaFX application with Ant script

I'm trying to generate a executable jar for my JavaFX application with Ant, and the difference between my jar and the one generated by the JavaFX Packager is that the latter include classes from com.javafx.main package.
How can I tell in my Ant script to include these classes in the jar as well ?

A:

The ant file you're using must have the special fx-tasks to deploy the jar, and not the ant built-in jar tasks.  Here's a sample ant target for generating a jar with JavaFX:
<target name="jar" depends="compile">
        <echo>Creating the main jar file</echo>  
        <mkdir dir="${distro.dir}" />
        <fx:jar destfile="${distro.dir}/main.jar" verbose="true">
            <fx:platform javafx="2.1+" j2se="7.0"/>
            <fx:application mainClass="${main.class}"/>

            <!-- What to include into result jar file?
                 Everything in the build tree-->
            <fileset dir="${classes.dir}"/>

            <!-- Define what auxilary resources are needed
                  These files will go into the manifest file,
                  where the classpath is defined -->
             <fx:resources>
                <fx:fileset dir="${distro.dir}" includes="main.jar"/>
                <fx:fileset dir="." includes="${lib.dir}/**" type="jar"/>
                <fx:fileset dir="." includes="."/>
            </fx:resources>

            <!-- Make some updates to the Manifest file -->
            <manifest>
               <attribute name="Implementation-Vendor" value="${app.vendor}"/>
               <attribute name="Implementation-Title" value="${app.name}"/>
               <attribute name="Implementation-Version" value="1.0"/>
            </manifest>
        </fx:jar>
    </target>

Note, that you must have a taskdef defined somewhere in the script:
<taskdef resource="com/sun/javafx/tools/ant/antlib.xml"      
            uri="javafx:com.sun.javafx.tools.ant"
            classpath="${javafx.sdk.path}/lib/ant-javafx.jar"/>

and the project tag must have the fx xmlns reference:
<project name = "MyProject" default ="compile"  xmlns:fx="javafx:com.sun.javafx.tools.ant">

The generated jar file should now include the classes from javafx.main and the manifest will include them as an entry point into the application. More info: 
http://docs.oracle.com/javafx/2/deployment/packaging.htm

