Skip navigation
The Australian National University

Writing Hello World in JFX using Eclipse and Mercurial

  1. Start Eclipse, either using the menu, or a terminal.

  2. Select the workspace you wish to use (sticking with the default should be fine).

  3. Wait for eclipse to finish loading.

  4. Go to the workbench (you'll only see this screen the first time you use Eclipse).

  5. Your empty workbench should look something like this.

  6. Create a new Mercurial repository for your project, using "New", "Other", "Mercurial..".

  7. You should see a dialogue like this. We're just going to create the repository in your home directory, so select "Local..."

  8. Create a folder called "testhg" (or whatever you like) as your repository.

  9. After pressing OK, you should see something like this. Note the repository at the bottom. Sometimes when you first create the repository, it is necessary to click on the little plus sign near the cursor in the image below.

  10. Use "New", "New Java Project..." menu options to create a new Java project.

  11. Call the new project "jfxtest" (or whatever you wish).

  12. Unselect the "Use default location" option.

  13. Use the "Browse" button to navigate to the repository you created above, "testhg", and press "OK".

  14. Your project should look something like this. Note the small black icon near the project name. This indicates that the project in a Mercurial repository and that there are uncommitted changes.

  15. Right mouse click on the project's icon and select "Properties", and click on "Java Build Path".

  16. Click on the "Libraries" tab, and click "Add External JARs...".

  17. Use the file selector to navigate to /usr/local/javafx/rt/lib/jfxrt.jar or wherever jfxrt.jar is on your system. (In the labs, you'll need to click on "File System" to get to the root of the file system, so you can find /usr.

  18. After the above step, you should see the jfxrt.jar icon in your list of libraries.

  19. Now you can create a class. Use "New", "Class" to do this. Call the class JFXTest (or whatever), and set the "SuperClass" to javafx.application.Application.

  20. Select the button for creating a stub for public static void main(String[] args).

  21. You should now have a class that looks something like this:

  22. Edit your class to match the following code, resolving any unfound libraries (little red marks on left), ensuring you select libraries from somewhere in the javafx tree, when prompted.

  23. Click on the green run button and you should see something like the following:

Updated:  26 September 2012 / Responsible Officer:   JavaScript must be enabled to display this email address. / Page Contact:   JavaScript must be enabled to display this email address.