Last updated December 12, 2008 00:56, by stemkev

Java FX for Eclipse


Install JavaFX SDK

Download JavaFX SDK for Windows or Mac Os X. Follow the installation instructions.

Install Eclipse

The plugin requires Eclipse 3.4 or newer. We recommend downloading Eclipse IDE for Java EE Developers for Windows or Mac OS X. Then follow the installation instructions.

Install Plugin

  1. Download plugin:
  2. for Windows
  3. for Mac OS X
  4. Unzip into the eclipse installation directory
  5. There should be new files in ECLIPSE_ROOT/plugins and ECLIPSE_ROOT/features
  6. Run Eclipse

Hello World

Creating JavaFX Project and Configuring JavaFX SDK

  1. Start eclipse. You will see the basic layout of the workbench.
    New empty workbench
  2. In the Package Explorer view right-click and select New > Java Project
    New Java Project menu
  3. Create a new JavaTM project.
    New empty workbench
  4. Name it MyJavaFXProject and press the Finish button. The new project appears in the Package Explorer.
    New project created
  5. Right-click on the newly created project and select JavaFX > Add JavaFX Nature.
    Add JavaFX nature to Java Project
  6. The JavaFX perspective is activated. If this is first time you are adding the JavaFX nature to a Java Project you will be asked to set the JAVAFX_HOME property.
    Error, JavaFX SDK home not set up.
    To set up the JAVAFX_HOME property, follow these steps:
    1. Press OK on message dialog. No thanks, I prefer Cancel button.
    2. You should see the below dialog with JAVAFX_HOME set to (empty) value.
      Preferences: Classpath Variables
    3. Press Edit... button on the right side to bring up the edit window.
      Edit classpath variable
    4. Press the Folder... button and select the installation folder of the JavaFX SDK.
      Select instalation folder of JavaFX SDK
    5. Press OK on Folder Selection dialog, press OK on Edit Variable Entry dialog.
      Result of setting JAVAFX_HOME property
    6. Press OK on Preferences dialog. The JAVAFX_HOME variable has been set. If you decided to select the Cancel button on the error dialog you will skip this setup and the system will never ask you for this again. To set this up later just follow these instructions.
  7. Voila! you have created your first JavaFX Project.
    Opened JavaFX Perspective with Java Project with JavaFX nature

Adding Files

  1. Expand MyJavaFXProject. Left click on src folder. Then select New > Package and type into the Name field the package name com.sun.eclipse.example.
    Adds new Empty Script file into folder.
  2. Left click on src/com.sun.eclipse.example folder. Then select New > Empty Script.
    Adds new Empty Script file into folder.
  3. The New File wizard will appear. Type Main into the Name field.
    New file wizzard
  4. Press the Finish button and an empty new JavaFX script will be created.
    New empty FX script
  5. Let's focus on Snippets view. There are a lot of code snippets to help you develop your application. Expand Applications and select Stage.
    Snippets View
  6. Drag and drop a Stage node into the editor window. The Insert Template: Stage dialog appears. Change the value of the title variable to Hello World!.
    Result after drop
  7. Press the Insert button to insert the resulting template into the source code.
    Result in editor
  8. Mission accomplished, Sir!


Running the application in Eclipse is extremely easy.

  1. Press the Run button on the toolbar to launch the application.
    Run icon
  2. If you are running for the first time the Edit Configuration dialog appears.
    All options are set to default values. The most interesting part is the Profile - Target option. Here you can set up the execution environment. Possible options are:
    • Desktop profile - Run as Application
    • Desktop profile - Run as Applet
    • Desktop profile - Run with WebStart
    • Mobile Profile[?] - Run in Emulator
  3. Press Run to start the application. The console window will appear notifying you about progress of execution.
    Running application


Building in Eclipse is provided automatically by default. For more building options open the Project menu

Configuration Options

  1. Right-click the project in the Package Explorer, and select Properties.
    Menu: Project Properties
  2. The Properties dialog appears. Select JavaFX Defaults.
    Properties: JavaFX Defaults
    Here you can edit several default parameters used during the execution and deployment process of JavaFX Projects. For more information about the meaning of available options see the JavaFX Packager Documentation.

JavaFX Help

The plugin provides easy access to the JavaFX SDK documentation. You can invoke help by Help > Java FX > JavaFX Script Documentation or press Ctrl + F1
JavaFX SDK Help


  • At any time you can setup or change the JAVAFX_HOME variable by following these steps:
    1. Open Window > Preferences
    2. Expand Java > Build Path and select Classpath Variables
    3. Edit JAVAFX_HOME
  • You can switch profiles in SDK by following these steps:
    1. Right click on project name. Select Properties > Java Build Path > Libraries
    2. Double click on JavaFX System Library. The Edit Library dialog appears. Here you can set the profile to use.
      Dialog: Edit JavaFX System Library

  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2014, Oracle Corporation and/or its affiliates
(revision 20160708.bf2ac18)
Please Confirm