Setting Up NetBeans IDE With JavaFX

JavaFX provides a powerful Java-based UI platform capable of handling large-scale data-driven business applications. JavaFX 2 is a major update to the JavaFX platform. Starting with this version, developers can create JavaFX applications completely in Java. This document describes how to set up a JavaFX-enabled Java platform that will enable you to start developing JavaFX 2 applications in NetBeans IDE.

Notes:

  • If you are using NetBeans IDE 7.1.2, 7.2, or 7.2.1, refer to the Setting Up NetBeans IDE 7.1.2, 7.2, or 7.2.1 With JavaFX tutorial.
  • If you are using NetBeans IDE 7.4, you do not need to set up an "FX-enabled" Java platform in order to utilize JavaFX support in the IDE. You can develop JavaFX projects in the IDE if you install any standard Java platform that is JDK 7 Update 6 or newer (JDK 7 Update 10 or newer is strongly recommended). See NetBeans IDE 7.4 Release Notes for details.

Contents

Content on this page applies to NetBeans IDE 7.3

To follow this tutorial, you need the following software and resources.

Software or Resource Version Required
NetBeans IDE 7.3
Java Development Kit (JDK) 7 update 10 or more recent
JavaFX SDK (cobundled with JDK) 2.2.4 or more recent

Notes:

  • Starting with Java SE 7 Update 10, JavaFX SDK is cobundled with the JDK for Windows, Mac OS X, and Linux x86/x64.
  • If you want to continue to use Java SE 6 on Windows, the latest security release, Java SE 6 Update 37, is recommended for JavaFX 2.2.4. For more information, see JavaFX 2.2.4 Installation for Windows.

Upgrading JavaFX 2

If you want to upgrade from one version of JavaFX 2 to another (for example, from JavaFX 2.1 to JavaFX 2.2.x), it is safest to uninstall the older version of JavaFX 2.

Manually uninstall the old version and make sure its directories are deleted. The JavaFX installer does not always uninstall older versions of JavaFX 2 correctly, which can lead to the wrong version being used.

Additionally, you might encounter problems if the new JavaFX SDK location differs from the old location. The existing default JavaFX-enabled platform would still point to the old location. In this case, open Tools > Java Platforms, delete the old default JavaFX-enabled platform and create a new default JavaFX-enabled platform using the updated version of JavaFX 2.

Creating a JavaFX-Enabled Java Platform

NetBeans IDE requires a JavaFX-enabled Java platform in order to use JavaFX 2.2.4. This section describes how to create a JavaFX-enabled Java platform in the IDE.

NetBeans IDE attempts to create a JavaFX-enabled Java platform when you choose a JavaFX project in the New Project wizard or when you open an existing JavaFX project for the first time. A warning appears if the IDE cannot create the JavaFX-enabled Java platform automatically. In this case you must create the JavaFX-enabled Java platform manually. You can create additional JavaFX-enabled Java platforms, for example, if you want them to use a different Java JDK.

The procedure in this section is divided into the following two parts, to reflect automatic and manual Platform creation.

Opening the New JavaFX Application Wizard

The first step in creating a JavaFX-enabled Java platform is to open the IDE's New JavaFX Application wizard. (Alternatively, you may open the New JavaFX Preloader wizard.) If the IDE does not find a JavaFX-enabled Java platform, the IDE attempts to generate a JavaFX-enabled Java platform. If the IDE successfully generates a JavaFX-enabled Java platform your setup is complete. If the IDE does not generate a JavaFX-enabled Java platform, you must create a platform manually.

To open the New JavaFX Application Wizard:

  1. In the IDE, choose File > New Project or click the New Project icon (New Project icon).
    The New Project wizard opens.

    Flow view with added components

  2. Select the JavaFX category and select JavaFX Application under Projects. Click Next.
    The IDE activates the JavaFX 2 feature and generates a JavaFX-enabled Java platform.

    New JavaFX Application wizard showing autogenerated platform

    The IDE generates a JavaFX-enabled Java platform. This JavaFX-enabled platform uses the same JDK sources that the IDE uses by default. The name of the generated platform is Default JavaFX Platform. The IDE automatically selects this platform. Your setup is complete, unless you want to create an additional JavaFX-enabled Java platform using a different JDK. You can now do the Tutorials. If you want to create additional JavaFX-enabled Java platforms, see Creating a JavaFX-Enabled Platform Manually.

Creating a JavaFX-Enabled Platform Manually

You need to create a JavaFX-enabled Java platform manually if you want a JavaFX-enabled platform based on a Java JDK other than the JDK that the IDE uses by default. For example, your IDE uses Java JDK 1.6.0 update 37 on Windows, but you want to build JavaFX applications using Java JDK 7 Update 11.

To create a JavaFX-enabled platform manually:

  1. Open the NetBeans IDE Java Platform Manager. You can open the Platform Manager in the following ways:
    • In the New JavaFX Application or New JavaFX Preloader wizard, click Manage Platforms...
    • Expand the Tools menu and select Java Platforms.
    • Open the Project Properties of a Java project. Go to the Libraries page. Click Manage Platforms...
  2. Click Add Platform... to open the Add Java Platform wizard on the Choose Java Platform panel. Specify the location of your desired JDK.

    Choose Java Platform panel of Add Java Platform wizard, showing available platforms

  3. Select a JDK. You must select JDK JDK 7 Update 10 or later (or 1.6 update 37 or later). Click Next. The Platform Name panel opens.

    Platform Name panel of Add Java Platform wizard

  4. Give your new platform an arbitrary, descriptive name and click Finish to return to the Platform Manager. You can see that the platform you created is now listed in the left pane.

    Platform Manager showing new platform

  5. Select the platform you created. Open the JavaFX tab for that platform. Currently, JavaFX is not enabled for this platform. Select the Enable JavaFX box.

    JavaFX enabled

    The JavaFX SDK, JavaFX Javadoc, and JavaFX Runtime fields are now filled in. You do not need anything in the Sources field.
  6. Click Close.
    Your JavaFX-enabled platform is complete.

Tutorials

After you set up NetBeans IDE to use JavaFX 2.2.4, try to do the JavaFX tutorials as NetBeans projects.

Troubleshooting

  • I get a warning that my JavaFX Runtime is obsolete. Did you ever install an earlier version of JavaFX 2? The installer might not have uninstalled the old Runtime correctly. Fix: Manually uninstall any older version of JavaFX 2. Be sure to delete any directories that remain after uninstalling.
  • I have another problem that you don't describe in this document! If you think something is missing from this document, click the Send Feedback on This Tutorial link below and let the writers know. If you think you have found a bug in NetBeans IDE support for JavaFX 2, please report it. On the enter_bug.cgi page, select the javafx product.

Back to the Learning Trail

get support for the NetBeans

Support


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo