ANT JAR file for JavaFX Application

ant, java, javafx-2

Solution

You're missing the fx: namespace declaration in your project. Rather than

<project name="XYZ" basedir=".">

you need something like:

<project name="XYZ" basedir="."
     xmlns:fx="javafx:com.sun.javafx.tools.ant">

(This is from the documentation you linked to, prior page, §12.3 Using JavaFX Ant Tasks.)

Problem

I have successfully complied the JavaFX code using Build Script with the previous help. Now I can not able to create JAR file uisng ANT for my application. I am adding sample script in build.xml. My requirement is to create a simple JAR file of my JavaFx XYZ application. ``` <project name="XYZ" basedir="."> <property name="WorkingFolder" location="XYZSourceData"/> <property name="ClassPath" location="C:\Program Files\Oracle\JavaFX 2.2 Runtime\lib\jfxrt.jar;C:\Program Files\Java\jdk1.7.0_09\lib\ant-javafx.jar;"/> <target name="init"> <echo message="Java installation directory: ${java.home}"/> <!-- Create the time stamp --> <tstamp/> <delete dir="${WorkingFolder}/build"/> <delete dir="${dist}"/> <mkdir dir="${WorkingFolder}/CustomJars"/> </target> <target name="Compilingxyz" depends="init"> <mkdir dir="${WorkingFolder}/build"/> <taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri="javafx:com.sun.javafx.tools.ant" classpath=".;C:\Program Files\Oracle\JavaFX 2.2 Runtime\lib\jfxrt.jar"/> <javac classpath="${ClassPath};${WorkingFolder}/CustomJars/*.jar;" srcdir="${WorkingFolder}/src/com/xyz" destdir="${WorkingFolder}/build"/> </target> <target name="CreatingxyzJars" depends="Compilingxyz" description="generate the distribution" > <taskdef resource="com/sun/javafx/tools/ant/antlib.xml" uri="javafx:com.sun.javafx.tools.ant" classpath="C:\Program Files\Java\jdk1.7.0_09\lib\ant-javafx.jar"/> <fx:jar destfile="${WorkingFolder}/CustomJars/XYZ.jar"> <fx:application name="XYZ" mainClass="com.xyz.main.XYZEntryFX"/> <fx:resources> <fx:fileset dir="${WorkingFolder}/build" includes="${WorkingFolder}/libs/*.jar"/> </fx:resources> <fileset dir="${WorkingFolder}/resources"/> </fx:jar> </target> ``` I am getting following error - ``` BUILD FAILED C:\Users\JavaUser4\Desktop\2012.12FX\build.xml:83: The prefix "fx" for element " fx:jar" is not bound. ``` Total time: 0 seconds What is the missing part? I have Java Desktop application. How can I create a ANT JAR for Java Fx Application. Please Help. I am taking reference of following example - Example

Original source

Related problems