Installing JavaFX on Personal Machines
At this time, we recommend installing version 12.0.2 of JavaFX. Different versions of JavaFX can be found online however, and the installation process will be the same.
Installing On Windows
- Go to https://gluonhq.com/products/javafx/ and download JavaFX Windows SDK, not JMODS. We recommend keeping the unzipped version of the file in your Downloads folder.
- Open a File Explorer window and find the javafx-sdk-12.0.2/lib folder.
- Copy the path to this location.
- You now need to add an environment variable for JavaFX. In your terminal, using your copied path, run the command: set PATH_TO_FX="path\to\javafx-sdk-12.0.2/lib".
- You should now be able to compile and run programs using JavaFX.
Installing On MacOS
- Go to https://gluonhq.com/products/javafx/ and download JavaFX Mac OS X SDK.
- Navigate to Downloads and unzip the file by double clicking on it.
Find the absolute path to your Downloads folder. Open a new terminal window and run the command: cd Downloads; pwd . Copy the resulting path.
In your terminal, run the command: export PATH_TO_FX="[path-to-downloads]/javafx-sdk-12.0.1/lib", pasting in the absolute path to your Downloads folder.
- (Note: you will need to do this final step each time you open a new terminal window, as the PATH_TO_FIX variable does not carry over between terminal windows.)
Installing On Ubuntu (18.04 or newer)
Open a command line
Type "apt install openjfx" to get the package
- It is installed to /usr/share/openjfx/lib
In your terminal, run the command: export PATH_TO_FX="/usr/share/openjfx/lib", pasting in the absolute path to your Downloads folder.
- (Note: you will need to do this final step each time you open a new terminal window, as the PATH_TO_FIX variable does not carry over between terminal windows.)
Running Programs
You should now be able to compile and run programs using JavaFX, using the syntax:
javac --module-path $PATH_TO_FX program_name.java
java --module-path $PATH_TO_FX program_name