Getting Started with JavaFX Scene Builder 1.0

Previous

9 Compile and Run the Application

You are ready to see your application in action. You can use either NetBeans IDE or the Apache Ant utility to compile and run the IssueTrackingLite application.

Use NetBeans IDE

Use NetBeans IDE to build and run the NetBeans project in which you saved the IssueTracking.fxml file.

  1. In the NetBeans IDE 7.2 window, right-click the IssueTrackingLite project node in the Projects window and select Run. NetBeans IDE compiles the project and if no errors are encountered, it displays an application similar to Figure 9-1. Click the image to enlarge it.

    Figure 9-1 Completed UI for Issue Tracking Sample (Click image to enlarge.)

    Description of Figure 9-1 follows
    Description of "Figure 9-1 Completed UI for Issue Tracking Sample"

  2. In the list view on the left, select Project1 and in the table view on the right, select the row with the TT-2 in the Name column. Data is displayed in the details section, as shown in Figure 9-1.

  3. If you encounter any errors, look at the Output window and determine the possible causes of the errors. Some troubleshooting ideas are as follows:

    • Check that all of the fx:id values were entered correctly. The fx:id values in the FXML layout must match the values that the controller source classes expect.

    • Check that you entered the method name correctly in the Event binding section.

    • On the Mac OS X platform, check that you have properly configured a JavaFX 2.2 enabled platform in your NetBeans IDE installation. At the present, the JavaFX-enabled platform is not automatically created for you on the Mac OS X platform.

Use the Apache Ant Utility

If you choose not to run the application in NetBeans IDE, use the Apache Ant utility (version 1.8 or later) to build and run the application on the command line. Enter a command similar to the one in Example 9-1 if you are using JDK 7 or Example 9-2 if you are using JDK 6 on a Windows platform.

Example 9-1 Apache Ant Command to Run the Application When Using JDK 7

ant -Dplatforms.Default_JavaFX_Platform.home=<JAVA_HOME>
    -Dplatforms.Default_JavaFX_Platform.javafx.runtime.home==<JAVA_HOME>/jre
    -f <JavaFX_App_Name>/build.xml
    <TARGET>

Example 9-2 Apache Ant Command to Run the Application When Using JDK 6

ant -Dplatforms.Default_JavaFX_Platform.home=<JAVA_HOME>
    -Djavafx.sdk=<JAVAFX_22_SDK_HOME>
    -Djavafx.runtime=<JAVAFX_22_RUNTIME_HOME>
    -f <JavaFX_App_Name>/build.xml
    <TARGET>


In the above examples, the main values for <TARGET> are clean, jar, and run. For example, to run the IssueTrackingLite application on the Windows platform, enter something similar to the command in Example 9-3 if you are using JDK 7 and Example 9-4 if you are using JDK 6 on a Windows platform. You can set <TARGET> with the value of -projecthelp to get a list of available targets.

Example 9-3 Using Apache Ant to Run IssueTrackingLite on a Windows Platform When Using JDK 7

ant -Dplatforms.Default_JavaFX_Platform.home="C:\Program Files\Java\jdk1.7.0_06" \
    -Dplatforms.Default_JavaFX_Platform.javafx.runtime.home=\
    "C:\Program Files\Java\jdk1.7.0_06\jre" \
    -f IssueTrackingLite/build.xml run

Example 9-4 Using Apache Ant to Run IssueTrackingLite on a Windows Platform When Using JDK 6

ant -Dplatforms.Default_JavaFX_Platform.home="C:\Program Files\Java\jdk1.6.0_33" \
    -Dkjavafx.sdk="C:\Program Files\Oracle\JavaFX 2.2 SDK" \
    -Djavafx.runtime="C:\Program Files\Oracle\JavaFX 2.2 Runtime" \
    -f IssueTrackingLite/build.xml run


To run the IssueTrackingLite application on a Mac OS X platform with Java SE 7 update 6 software installed, type the command shown in Example 9-5.

Example 9-5 Using Apache Ant to Run IssueTrackingLite on a MacOS Platform

ant -Dplatforms.Default_JavaFX_Platform.home=\
       /Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk/Contents/Home \ 
    -Dplatforms.Default_JavaFX_Platform.javafx.runtime.home=\
       /Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk/Contents/Home/jre \
    -f IssueTrackingLite/build.xml run
Previous