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
- 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)
- Install e(fx)clpise (https://www.youtube.com/watch?v=bk28ytggz7E)
- Open Eclipse Marketplace.
- Search for ‘JavaFX’
- Install e(fx)clipse plugin
- 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:
- File –> New Project –> Java FX Project
- Make sure you remove e(fx)clipse plugin JavaFX SDK as it is an old version of JavaFX from your build path
- 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.