How to Run Java files Using JavaFX
How to Run Java files Using JavaFX
- Download a JavaFX runtime for your operating system and unzip it to a desired location:
- Add an environment variable pointing to the lib directory of the runtime. As I use
oh my zsh
on my Mac, I open the.zshrc
file usingvi .zshrc
and add an envrionment:
1 | # JavaFX |
- We can compile files by adding the modules:
1 | javac --module-path $PATH_TO_FX |
- Likewise for the commands
java
andjavadoc
need to be extended. Therefore, you may want to use aliases. To add aliases, go to the folder~/.oh-my-zsh/custom
and create a new.zsh
file(I usealiases.zsh
), then add aliases to this file:
- Now we can compile and run Java files using JavaFX: