Java FX for Eclipse

Table of content

  1. Installation
    1. Install JavaFX SDK
    2. Install Eclipse
    3. Install Plugin
  2. Hello World
    1. Creating JavaFX Project and configuring JavaFX SDK
    2. Adding files
    3. Running
    4. Building
    5. Configuration options
    6. JavaFX Help


Install JavaFX SDK

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

Install Eclipse

Plugin require Eclipse 3.4 or newer. We recomend downloading Eclipse IDE for Java EE Developers for Windows or Mac OS X. Then follow the installation instructions.

Install plugin

  1. Download plugin:
  2. Unzip into eclipse installation directory
  3. There should be new files in ECLIPSE_ROOT/plugins and ECLIPSE_ROOT/features
  4. Run Eclipse

Hello World

Creating JavaFX Project and configuring JavaFX SDK

  1. Start eclipse. You will see the basic layout of workbench.
    New empty workbench
  2. In Package Explorer view click right mouse and select New > Java Project
    New Java Project menu
  3. Create new JavaTM project.
    New empty workbench
  4. Name it MyJavaFXProject and press Finish button. The new project appears in Package Explorer.
    New project created
  5. Open project popup menu 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 JavaFX nature into Java Project you will be asked for setting up JAVAFX_HOME property.
    Error, JavaFX SDK home not set up.
    To set up JAVAFX_HOME property follow steps bellow:
    1. Press OK on message dialog. No thanks, I preffer Cancel button.
    2. You shoud see dialog below with JAVAFX_HOME set to (empty) value.
      Preferences: Classpath Variables
    3. Press Edit... button on rigth side to bring up edit window.
      Edit classpath variable
    4. Select Folder... button and select instalation folder of 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 up.
    If you desided to select Cancel button on error dialog you will skip this setup and system will never ask you for this again. To setup this later just follow this instructions.
  7. Voila! you have 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 Name 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 wizzard will appear. Type Main into Name field.
    New file wizzard
  4. Press Finish button and empty new JavaFX script is created.
    New empty FX script
  5. Let's focuse on Snippets view. There is a lot of code snippets to help you develop your application. Expand Applications and select Stage.
    Snippets View
  6. Drag Stage into editor window and drop. The Insert Template: Stage dialog appers. Change title into Hello World!.
    Result after drop
  7. Press Insert button to insert template result into source code.
    Result in editor
  8. Mission acomplished, Sir!


Runnign application in Eclipse is extreemly easy.

  1. Press Run button on toolbar to lunch application.
    Run icon
  2. If you are running first time the Edit Configuration dialog appers.
    All options are setup to default values. The most interesting part is Profile - Target option. Here you can set up execution environment. Possible options are:
  3. Press Run to start application. The console window will appear notifying you about progress of execution.
    Running application


Building is in Eclipse platform provided automaticaly. For more building options open Project menu

Configuration options

  1. Select project in Package Explorer, right click 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 execution and deployment process of JavaFX Project. For more information about meaning of available options see JavaFX Packager Documentation.

JavaFX Help

Plugin provide easy acces into JavaFX SDK documentation. You can invoke help by Help > Java FX > JavaFX Script Documentation or press Ctrl + F1
JavaFX SDK Help