corner imagecorner image
IDEPlatformPluginsDocs & SupportCommunityPartners

Setting Up NetBeans IDE With JavaFX 2.0

JavaFX provides a powerful Java-based UI platform capable of handling large-scale data-driven business applications. JavaFX 2.0 is a major update to the JavaFX platform. Starting with this version, developers can create JavaFX applications completely in Java.

NetBeans IDE supports the creation of JavaFX 2.0 applications.

A bundled installation of NetBeans IDE with the JavaFX 2.0 SDK is available from the JavaSE download site. JavaFX SDK is included in the Java 7u2 bundle you download from that site. You may also install NetBeans IDE and JavaFX 2.0 SDK separately. This document describes how to set up NetBeans IDE with JavaFX 2.0 SDK when you install the IDE and the SDK separately.

Contents

Content on this page applies to NetBeans IDE 7.1

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

Software or Resource Version Required
NetBeans IDE 7.1. Java SE, Java EE, or All
JavaFX 2.0 SDK Latest release

Installing NetBeans IDE and JavaFX 2.0 SDK

Install JavaFX 2.0 from the JavaFX download site. JavaFX 2.0 requires Java JDK 1.6.0 update 26 or later, or Java 7. JavaFX does not run on all operating systems. Check the JavaFX System Requirements document to see which platforms are supported by JavaFX. The system requirements for JavaFX 2.0 also let you install NetBeans IDE.

Note that when you install JavaFX 2.0 SDK, you actually install two packages: the JavaFX 2.0 SDK and the JavaFX 2.0 Runtime.

If you are using Windows, consider installing JavaFX 2.0 to the default location (C:\Program Files\Oracle\). NetBeans IDE checks the default Windows locations for JavaFX 2.0 SDK and JavaFX 2.0 Runtime. If JavaFX 2.0 is in the default locations, you have less to configure. Also note that if you use the Windows .exe installer, you can change the installation location of the SDK package but not the Runtime package. JavaFX 2.0 Runtime is always installed to the default location by the .exe installer.

Warning: If you have older versions of JavaFX 2.0 (pre-b46) installed on your computer, manually uninstall them and make sure their directories are deleted. The JavaFX installer does not always uninstall older versions of JavaFX 2.0 correctly, which can lead to the wrong version being used. NetBeans IDE does not support earlier versions of JavaFX 2.0.

Creating a JavaFX-Enabled Java Platform

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

NetBeans IDE attempts to create a JavaFX-enabled Java platform when you open the New JavaFX Application or New JavaFX Preloader wizard for the first time. If NetBeans IDE cannot create the JavaFX-enabled Java platform automatically, a warning appears. 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 different Java JDKs.

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

  • Opening the New JavaFX Application Wizard. This is the universal starting point. When you open the wizard, NetBeans IDE attempts to create a JavaFX-enabled Java platform. If NetBeans succeeds, you are finished.
  • Creating a JavaFX-Enabled Platform Manually. If automatic platform generation fails, or you want an additional JavaFX-enabled platform, you must create the platform manually.

Opening the New JavaFX Application Wizard

The first step in creating a JavaFX-enabled Java platform is to open NetBeans IDE's New JavaFX Application wizard. (You may instead 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.

Note: Automatic platform generation works on Windows with JavaFX SDK and Runtime installed to the default location (C:\Program Files\Oracle\).

To open the New JavaFX Application Wizard:

  1. In the IDE, click the New Project icon (or File>New Project or Ctrl-Shift-N). The New Project wizard opens.
    First panel of New Project window with JavaFX Application selected
  2. Select the JavaFX category. Under Projects, select JavaFX Application. Click Next. The Name and Location panel opens. The IDE looks for the JavaFX SDK and attempts to generate a JavaFX-enabled Java platform.

You now see one of two screens, depending on whether or not NetBeans IDE generated a JavaFX-enabled platform:

  • Platform was generated: 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 JFX 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.
    New JavaFX Application wizard showing autogenerated platform
  • Platform was not generated: The JavaFX Platform list does not show any JavaFX-enabled platforms. A warning appears at the bottom of the panel. Go to Creating a JavaFX-Enabled Platform Manually.
    New Project wizard Name and Location panel, with a non-JavaFX-enabled Java platform selected

Creating a JavaFX-Enabled Platform Manually

You need to create a JavaFX-enabled Java platform manually in the following cases:

  • NetBeans IDE failed to generate a JavaFX-enabled Java platform when you opened the New JavaFX Application or New JavaFX Preloader wizard.
  • You want a JavaFX-enabled platform based on a different Java JDK than the JDK that the IDE uses by default. For example, your IDE uses Java JDK 1.6.0 update 27, but you want to build JavaFX applications using Java 7.

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... The Add Java Platform wizard opens on the Choose Java Platform panel. Browse for your desired JDK.
    Choose Java Platform panel of Add Java Platform wizard, showing available platforms
  3. Select a JDK. You must select JDK 1.6 update 26 or later (or JDK 7). Click Next. The Platform Name panel opens.
    Platform Name panel of Add Java Platform wizard
  4. Give your new plaform an arbitrary, descriptive name and click Finish. You return to the Platform Manager. The platform you created is listed.
    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. Tick the Enable JavaFX box. A warning appears that the JavaFX platform is invalid.
  6. Click Browse next to the JavaFX SDK field. Browse for the JavaFX 2.0 SDK folder.
    Browsing for JavaFX 2.0 SDK
  7. Click Open. You return to the Java Platform Manager. The JavaFX SDK and JavaFX Javadoc fields are now filled in. If JavaFX Runtime 2.0 is in the same directory as JavaFX 2.0 SDK, the JavaFX Runtime field is also filled in. If JavaFX Runtime is in a different directory than the SDK, browse for the Runtime. You do not need anything in the Sources field.

    Click Close if you have values for the JavaFX 2.0 SDK, JavaFX Javadoc, and JavaFX Runtime fields and there is no warning that the JavaFX platform is invalid. Your JavaFX-enabled platform is complete.
    Completed Java Platform Manager showing valid JavaFX 2.0 directories

  8. If you return to or open the New JavaFX Application wizard, you need to select the JavaFX enabled platform you created. Select the JavaFX 2.0-enabled platform you created from the JavaFX Platform list. If you had a warning that your selected Java platform did not have JavaFX support, that warning disappears.
    New JavaFX Application wizard with manually-created JavaFX platform selected

    You may either click Finish and create a project, or click Cancel. Your new platform persists even if you cancel the New Project wizard.

Tutorials

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

Troubleshooting

  • I've imported a JavaFX application that was developed on another machine, and it won't run although my machine has a JavaFX-enabled platform. Your JavaFX application (or preloader) contains the paths to JavaFX SDK and Runtime that are on the original machine. If you import this application on a machine with a different location for JavaFX SDK and Runtime, the paths are incorrect. Fix: Change the JavaFX paths in the application's Project Properties to match the location of JavaFX on the new machine. To open project properties, go to the Projects window, right-click on the project's node and select Properties.
  • Everything set up correctly but when I try to compile a JavaFX application, it crashes. Do you have an earlier version of JavaFX 2.0 than b46? Did you try an earlier version before installing the latest version? NetBeans IDE is compatible only with JavaFX 2.0 b46 or later. If you installed the latest version but still have this problem, the installer might not have uninstalled the old version correctly. Fix: Manually uninstall any older version of JavaFX 2.0 than b46. Be sure to delete any directories that remain after uninstalling.
  • I get a warning that my JavaFX Runtime is obsolete. Did you ever install an earlier version of JavaFX 2.0 than b46? The installer might not have uninstalled the old Runtime correctly. Fix: Manually uninstall any older version of JavaFX 2.0 than b46. Be sure to delete any directories that remain after uninstalling.
  • I've installed a new version of NetBeans, and I have problems when I open an existing JavaFX project. The JavaFX file format changed substantially after NetBeans IDE 7.1 Beta release. These changes can cause problems when you attempt to open 7.1 Beta FX projects in later versions of NetBeans IDE. See Issue 205249 for details.

    Note: In future versions (7.2+), NetBeans IDE will automatically update older (7.1+) JavaFX 2.0 projects to work with the newer version of NetBeans IDE. Progress on this feature is tracked at Issue 204765.

  • I have another problem that you don't describe in this document! If you think something is missing from this document, click the Send Us Your Feedback link below and let the writers know. If you think you have found a bug in NetBeans IDE support for JavaFX 2.0, please report it. On the enter_bug.cgi page, select the javafx product.

Back to the Learning Trail