<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
<!-- | |
Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. | |
--> | |
<html> | |
<head> | |
<title>Setting Up NetBeans IDE With JavaFX</title> | |
<meta name="KEYWORDS" content="NETBEANS, JAVAFX"> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<meta name="DESCRIPTION" content="How to set up NetBeans IDE to use JavaFX" > | |
<link rel="stylesheet" type="text/css" href="../../../netbeans.css" media="screen"></head> | |
<body> | |
<h1>Setting Up NetBeans IDE With JavaFX</h1> | |
<p>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.</p> | |
<p><b>Contents</b></p> | |
<p><img src="../../../images_www/articles/71/netbeans-stamp-71-72.gif" class="stamp" width="114" height="114" | |
alt="Content on this page applies to NetBeans IDE 7.1" | |
title="Content on this page applies to NetBeans IDE 7.1"></p> | |
<ul> | |
<li><a href="#installing">Installing NetBeans IDE and JavaFX</a> </li> | |
<li><a href="#upgrade">Upgrading JavaFX 2</a></li> | |
<li><a href="#create-platform">Creating a JavaFX-Enabled Java Platform</a> | |
<ul> | |
<li><a href="#open-newapp-wiz">Opening the New JavaFX Application Wizard</a></li> | |
<li><a href="#create-platform-manual">Creating a JavaFX-Enabled Platform Manually</a></li> | |
</ul> | |
</li> | |
<li><a href="#tutorials">Tutorials</a></li> | |
<li><a href="#troubleshooting">Troubleshooting</a></li> | |
</ul> | |
<p><b>To follow this tutorial, you need the following software and resources.</b></p> | |
<table> | |
<tbody> | |
<tr> | |
<th width="208" class="tblheader" scope="col">Software or Resource</th> | |
<th width="218" class="tblheader" scope="col">Version Required</th> | |
</tr> | |
<tr> | |
<td class="tbltd1"><a href="https://netbeans.org/downloads/index.html" target="_blank">NetBeans IDE</a></td> | |
<td class="tbltd1">7.1.2, 7.2</td> | |
</tr> | |
<tr> | |
<td class="tbltd1"><a href="http://www.oracle.com/technetwork/java/javafx/downloads/index.html" target="_blank">JavaFX SDK</a></td> | |
<td class="tbltd1">2.1, 2.2</td> | |
</tr> | |
</tbody> | |
</table> | |
<h2><a name="installing"></a>Installing NetBeans IDE and JavaFX</h2> | |
<p>Depending on your operating system, you can install the JavaFX SDK that is bundled with the Java JDK. | |
Alternatively, you can install the JavaFX SDK independently. | |
After you install JavaFX the IDE can create a JavaFX-enabled platform for you projects.</p> | |
<ul> | |
<li>For Windows, JavaFX 2.1 is bundled with JDK 1.7 update 4 and JavaFX 2.2 is bundled with JDK 1.7 update 6. | |
If the JavaFX libraries and runtime that are bundled with the JDK are installed in the default locations, | |
NetBeans IDE can <a href="#create-platform">create a JavaFX-enabled Java platform</a> automatically.</li> | |
<li>For Mac OS X, JavaFX 2.1 is embedded in Mac JDK 1.7 update 4 and JavaFX 2.2 is bundled with JDK 1.7 update 6. | |
After you install the JDK, NetBeans IDE can <a href="#create-platform">create a JavaFX-enabled Java platform</a> automatically.</li> | |
<li>You can download the JavaFX SDK standalone installer from the <a href="http://www.oracle.com/technetwork/java/javafx/downloads/index.html" target="_blank">JavaFX download site</a>. | |
JavaFX 2.1 and 2.2 require Java JDK 1.6.0 update 26 or later, or Java 7. JavaFX does not run on all operating systems. | |
Please consult the <a href="http://docs.oracle.com/javafx/release-documentation.html" target="_blank">JavaFX System Release Documentation</a> to see which platforms are supported by JavaFX. | |
</li> | |
</ul> | |
<p class="alert"><strong>Important:</strong> To develop with JavaFX on Mac OS, you need JDK 7 update 4 or later, JavaFX 2.1 or later, and NetBeans IDE 7.1.2 or later. | |
If you have NetBeans IDE 7.1 or 7.1.1, install all available updates to upgrade to NetBeans IDE 7.1.2.</p> | |
<p class="notes"><strong>Note:</strong> When you install JavaFX 2.1 on Windows, you actually install two packages: the JavaFX 2.1 SDK and the JavaFX 2.1 Runtime.</p> | |
<p>If you install JavaFX 2.1 to Windows manually, consider installing the JavaFX 2.1 libraries and runtime to the default location (<tt>C:/Program Files/Oracle/</tt>). | |
NetBeans IDE checks the default locations for the JavaFX. | |
If JavaFX 2 is in the default locations the IDE can automatically create a JavaFX-enabled Java platform. | |
The IDE can find the JavaFX SDK and runtime if you install JavaFX bundled with Java JDK.</p> | |
<p>If you install JavaFX 2.1 to Mac OS manually, there is no default location and you must <a href="#create-platform">create a JavaFX-enabled Java platform</a> manually.</p> | |
<h2 id="upgrade">Upgrading JavaFX 2</h2> | |
<p>If you want to upgrade from one version of JavaFX 2 to another (for example, from JavaFX 2.0 to JavaFX 2.1), it is safest to uninstall the older version of JavaFX 2.</p> | |
<p><span class="alert">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. </span></p> | |
<p>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 | |
<a href="#create-platform">create a new default JavaFX-enabled platform</a> using the updated version of JavaFX 2.</p> | |
<h2><a name="create-platform"></a>Creating a JavaFX-Enabled Java Platform</h2> | |
<p>NetBeans IDE requires a JavaFX-enabled Java platform in order to use JavaFX 2.1 and 2.2. | |
This section describes how to create a JavaFX-enabled Java platform in the IDE.</p> | |
<p>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.</p> | |
<p>The procedure in this section is divided into the following two parts, to reflect automatic and manual Platform creation.</p> | |
<ul> | |
<li><strong>Opening the New JavaFX Application Wizard.</strong> This is the universal starting point. | |
When you open the wizard, the IDE attempts to create a JavaFX-enabled Java platform. | |
If the IDE succeeds, you are finished. </li> | |
<li><strong>Creating a JavaFX-Enabled Platform Manually.</strong> If automatic platform generation fails, | |
or you want an additional JavaFX-enabled platform, you must create the platform manually.</li> | |
</ul> | |
<div class="indent"> | |
<h3><a name="open-newapp-wiz"></a>Opening the New JavaFX Application Wizard</h3> | |
<p>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.</p> | |
<p class="notes"><b>Note:</b> Automatic platform generation works on Windows with JavaFX SDK and Runtime installed to the default location | |
(<tt>C:\Program Files\Oracle\</tt>) and on Mac OS X with the JavaFX SDK bundled with JDK 7.</p> | |
<p><strong>To open the New JavaFX Application Wizard:</strong></p> | |
<ol> | |
<li>In the IDE, click the New Project icon (or File>New Project or Ctrl-Shift-N). The New Project wizard opens. <br> | |
<img src="../../../images_www/articles/72/java/javafx-setup/new-project.png" alt="First panel of New Project window with JavaFX Application selected" height="434" width="600" class="margin-around"></li> | |
<li>Select the JavaFX category and select JavaFX Application under Projects. Click Next. | |
<p>When you click Next you will see the Name and Location panel. | |
The IDE looks for JavaFX and attempts to generate a JavaFX-enabled Java platform. </p></li> | |
</ol> | |
<p>You now see one of two screens, depending on whether or not NetBeans IDE generated a JavaFX-enabled platform:</p> | |
<ul> | |
<li><b>Platform was generated:</b> 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 <a href="#tutorials">Tutorials</a>. | |
If you want to create additional JavaFX-enabled Java platforms, see <a href="#create-platform-manual">Creating a JavaFX-Enabled Platform Manually</a>.<br> | |
<img src="../../../images_www/articles/72/java/javafx-setup/newproject-autogen-platform.png" alt="New JavaFX Application wizard showing autogenerated platform" height="496" width="600" class="margin-around"> </li> | |
<li><strong>Platform was not generated:</strong> The JavaFX Platform list does not show any JavaFX-enabled platforms. | |
A warning appears at the bottom of the panel. | |
Go to <a href="#create-platform-manual">Creating a JavaFX-Enabled Platform Manually</a>.<br> | |
<img src="../../../images_www/articles/71/java/javafx-setup/newproject-nofx.png" alt="New Project wizard Name and Location panel, with a non-JavaFX-enabled Java platform selected" height="501" width="578" class="margin-around"> </li> | |
</ul> | |
<h3><a name="create-platform-manual"></a>Creating a JavaFX-Enabled Platform Manually</h3> | |
<p>You need to create a JavaFX-enabled Java platform manually in the following cases:</p> | |
<ul> | |
<li>NetBeans IDE failed to generate a JavaFX-enabled Java platform when you <a href="#open-newapp-wiz">stepped through the New JavaFX Application</a> or New JavaFX Preloader wizards.</li> | |
<li>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 27, but you want to build JavaFX applications using Java JDK 7. </li> | |
</ul> | |
<p><strong>To create a JavaFX-enabled platform manually:</strong></p> | |
<ol> | |
<li>Open the NetBeans IDE Java Platform Manager. You can open the Platform Manager in the following ways: | |
<ul> | |
<li>In the New JavaFX Application or New JavaFX Preloader wizard, click Manage Platforms...</li> | |
<li>Expand the Tools menu and select Java Platforms.</li> | |
<li>Open the Project Properties of a Java project. Go to the Libraries page. Click Manage Platforms...</li> | |
</ul> | |
</li> | |
<li>Click Add Platform... to open the Add Java Platform wizard on the Choose Java Platform panel. Specify the location of your desired JDK.<br> | |
<img src="../../../images_www/articles/71/java/javafx-setup/addplatform.png" alt="Choose Java Platform panel of Add Java Platform wizard, showing available platforms" height="448" width="551" class="margin-around"></li> | |
<li>Select a JDK. You must select JDK 1.6 update 26 or later (or JDK 7). Click Next. The Platform Name panel opens.<br> | |
<img src="../../../images_www/articles/71/java/javafx-setup/platform-name.png" alt="Platform Name panel of Add Java Platform wizard" height="292" width="560" class="margin-around"></li> | |
<li>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.<br> | |
<img src="../../../images_www/articles/71/java/javafx-setup/platform-mgr-newplatform-nofx.png" alt="Platform Manager showing new platform" height="462" width="600" class="margin-around"></li> | |
<li>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. A warning appears that the JavaFX platform is invalid.</li> | |
<li>Click Browse next to the JavaFX SDK field and locate the JavaFX 2.x SDK folder.<br> | |
<img src="../../../images_www/articles/71/java/javafx-setup/sdk-location.png" alt="Browsing for JavaFX 2.1 SDK" height="340" width="498" class="margin-around"></li> | |
<li>Click Open. You return to the Java Platform Manager. The JavaFX SDK and JavaFX Javadoc fields are now filled in. | |
If JavaFX Runtime 2.x is in the same directory as JavaFX 2.x SDK, the JavaFX Runtime field is also filled in. | |
If JavaFX Runtime is in a different directory than the SDK, browse and locate the Runtime. | |
You do not need anything in the Sources field. | |
<p>Click Close if you have values for the JavaFX 2.x SDK, JavaFX Javadoc, and JavaFX Runtime fields and there is no warning that the JavaFX platform is invalid. | |
Your JavaFX-enabled platform is complete.<br> | |
<img src="../../../images_www/articles/71/java/javafx-setup/platform-mgr-withfx.png" alt="Completed Java Platform Manager showing valid JavaFX 2.1 directories" height="408" width="600" class="margin-around"></p> | |
</li> | |
<li>If you return to or open the New JavaFX Application wizard, you need to select the JavaFX-enabled platform that you created. | |
Select the JavaFX-enabled platform that you created from the JavaFX Platform list. | |
If there was a warning that your selected Java platform did not have JavaFX support, that warning should disappear.<br> | |
<img src="../../../images_www/articles/72/java/javafx-setup/new-project-withfx.png" alt="New JavaFX Application wizard with manually-created JavaFX platform selected" height="496" width="600" class="margin-around"> | |
<p> You may either click Finish and create a project, or click Cancel. | |
Your new platform persists even if you cancel the New Project wizard.</p> | |
</li> | |
</ol> | |
</div> | |
<h2><a name="tutorials"></a>Tutorials</h2> | |
<p>After you set up NetBeans IDE to use JavaFX 2.x, try to do the <a href="http://download.oracle.com/javafx/" target="_blank">JavaFX tutorials</a> as NetBeans projects.</p> | |
<h2><a name="troubleshooting"></a>Troubleshooting</h2> | |
<ul> | |
<li><strong>I get a warning that my JavaFX Runtime is obsolete.</strong> Did you ever install an earlier version of JavaFX 2? The installer might not have uninstalled the old Runtime correctly. | |
<strong>Fix:</strong> Manually uninstall any older version of JavaFX 2. Be sure to delete any directories that remain after uninstalling.</li> | |
<li><strong>I have another problem that you don't describe in this document!</strong> | |
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 <a href="https://netbeans.org/community/issues.html">report it</a>. | |
On the enter_bug.cgi page, select the javafx product.</li> | |
</ul> | |
<div class="feedback-box" ><a href="/about/contact_form.html?to=3&subject=Feedback:%20JavaFX%20Setup">Send Feedback on This Tutorial</a></div> | |
<br style="clear:both;" /> | |
<p><a href="../../trails/matisse.html">Back to the Learning Trail</a></p> | |
</body> | |
</html> |