Set up JavaFX

Mon, Sep 18, 2023 One-minute read

Update your Java

Update your Java, please. Visit https://www.oracle.com/nz/java/technologies/downloads/ and choose your appropriate version. Ensure you note where you install it on your desk, as we will need to configure Eclipse later.

How to install and configure JavaFX

  1. Install https://openjfx.io . Remember the path where you unpacked the files to (i.e. on my machine: /Users/admin/eclipse-workspace/javafx-sdk-18.0.2/lib)
  2. Install e(fx)clpise (https://www.youtube.com/watch?v=bk28ytggz7E)
    1. Open Eclipse Marketplace.
    2. Search for ‘JavaFX’
    3. Install e(fx)clipse plugin
  3. Create a new user library where you add all jar files from /Users/admin/eclipse-workspace/javafx-sdk-18.0.2/lib. Call this library ‘JavaFX-Lib’ or something else you remember.

Creating a new JavaFX Project:

  1. File –> New Project –> Java FX Project
  2. Make sure you remove e(fx)clipse plugin JavaFX SDK as it is an old version of JavaFX from your build path
  3. Add the use library you created in step 3 above (i.e. ‘JavaFX-Lib’) to your build path.

Remember when you run your new JavaFX Project to change its configuration to allow running JavaFX as follows:

Run Configuration –> Arguments –> VM Arguments

--module-path /Users/admin/eclipse-workspace/javafx-sdk-18.0.2/lib --add-modules=javafx.controls

you will need to uncheck ‘use The -XstartOnFirstThread argument when Launching with SWT’ at least on macOS.