Last updated December 12, 2008 00:56, by stemkev
Java FX for Eclipse
Contents
- 1 Java FX for Eclipse
- 1.1 Installation
- 1.1.1 Install JavaFX SDK
- 1.1.2 Install Eclipse
- 1.1.3 Install Plugin
- 1.2 Hello World
- 1.2.1 Creating JavaFX Project and Configuring JavaFX SDK
- 1.2.2 Adding Files
- 1.2.3 Running
- 1.2.4 Building
- 1.2.5 Configuration Options
- 1.2.6 JavaFX Help
Installation
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
- Download plugin:
- com.sun.javafx.eclipse.feature-win32-win32-x86-1.0.zip for Windows
- com.sun.javafx.eclipse.feature-macosx-carbon-x86-1.0.zip for Mac OS X
- Unzip into the eclipse installation directory
- There should be new files in
ECLIPSE_ROOT/pluginsandECLIPSE_ROOT/features - Run Eclipse
Hello World
Creating JavaFX Project and Configuring JavaFX SDK
- Start eclipse. You will see the basic layout of the workbench.

- In the Package Explorer view right-click and select

- Create a new JavaTM project.

- Name it MyJavaFXProject and press the button. The new project appears in the Package Explorer.

- Right-click on the newly created project and select .

- 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_HOMEproperty.
To set up theJAVAFX_HOMEproperty, follow these steps:- Press on message dialog. No thanks, I prefer button.
- You should see the below dialog with
JAVAFX_HOMEset to (empty) value.
- Press button on the right side to bring up the edit window.

- Press the button and select the installation folder of the JavaFX SDK.

- Press on Folder Selection dialog, press on Edit Variable Entry dialog.

- Press on Preferences dialog. The
JAVAFX_HOMEvariable has been set. If you decided to select the 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.
- Voila! you have created your first JavaFX Project.

Adding Files
- Expand MyJavaFXProject. Left click on src folder. Then select and type into the field the package name com.sun.eclipse.example.

- Left click on src/com.sun.eclipse.example folder. Then select .

- The New File wizard will appear. Type Main into the field.

- Press the button and an empty new JavaFX script will be created.

- Let's focus on Snippets view. There are a lot of code snippets to help you develop your application. Expand and select Stage.

- Drag and drop a node into the editor window. The Insert Template: Stage dialog appears. Change the value of the title variable to Hello World!.

- Press the button to insert the resulting template into the source code.

- Mission accomplished, Sir!
Running
Running the application in Eclipse is extremely easy.
- Press the button on the toolbar to launch the application.

- 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 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
- Press Run to start the application. The console window will appear notifying you about progress of execution.

Building
Building in Eclipse is provided automatically by default. For more building options open the menu
Configuration Options
- Right-click the project in the Package Explorer, and select .

- The Properties dialog appears. Select .

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 or press Ctrl + F1
Footnotes:
- At any time you can setup or change the
JAVAFX_HOMEvariable by following these steps:- Open
- Expand and select
- Edit
JAVAFX_HOME
- You can switch profiles in SDK by following these steps:
- Right click on project name. Select
- Double click on . The Edit Library dialog appears. Here you can set the profile to use.






