Java Reference
In-Depth Information
The javafx runtime command is actually a wrapper that invokes the standard
java command that includes the JavaFX Script jar files. Because the JavaFX
compiler produces standard Java class files, you can include these class files,
along with any other JavaFX or Java class files, in a Java Archive (JAR) file. To
include these JAR files when running your JavaFX application, you just add
these jar file locations to your classpath when invoking the javafx command.
$ javafx -cp directory/MyJarFile.jar MyFirstApp
Now you have the basics for getting your JavaFX Script application up and run-
ning from the command line. This will suffice for small applications, but as your
application grows in size and complexity, you will quickly find that using the
command-line option becomes more cumbersome and complex. When your project
becomes this large, you may want to consider the NetBeans IDE for JavaFX 1.2,
Eclipse IDE with the JavaFX Plugin, or a build tool such as Apache Ant.
JavaFXC Ant Task
Apache Ant is a Java-based build tool written with the key advantage of being cross-
platform and OS independent. Ant makes it easy to develop on one platform and
deploy to another; as a result, it has become one of the more popular build tools
today. You can download the latest ant binaries from http://ant.apache.org/. If you
are using the NetBeans IDE for JavaFX 1.2, Ant is already included in the Net-
Beans IDE package.
The JavaFX Software Development Kit provides an Ant task for compiling JavaFX
Script source files. To declare this in an Ant build.xml file, use the taskdef Ant task.
For a simple first application, the build.xml file in Listing 1.4 compiles any .fx files
in the current directory. Ant is smart enough to know when files need to be com-
piled, so after a JavaFX Script file is compiled, it will not be compiled again until
the JavaFX Script source file is updated.
Listing 1.4
Sample Ant Build.xml File
<?xml version="1.0" encoding="UTF-8"?>
<project name="My First JavaFX Application"
default="compile" basedir="." >
<property name="javafx.dir"
value="${user.home}/javafx-sdk" />
<property name="javafx.lib" value="${javafx.dir}/lib" />
<property name="javafx.bin" value="${javafx.dir}/bin" />
Search WWH ::




Custom Search