Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ANT JAR file for JavaFX Application

Tags:

java

ant

javafx-2

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

like image 232
Ashish Pancholi Avatar asked Nov 01 '25 00:11

Ashish Pancholi


1 Answers

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.)

like image 153
martin clayton Avatar answered Nov 02 '25 13:11

martin clayton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!