JavaFX Custom File Extension Viewer boilerplate
This is a boilerplate for creating a JavaFX application that is capable of handling a custom file extension. There are some nuances/caveats to getting this right (especially on MacOS), which are described in the accompanying blog post. In this example, the application is set up to handle
.pew files with the bundle identifier
Makefile will generate app bundles that simply print out the opened file path:
An example macOS bundle (.dmg) built using Github Actions is available here to check out.
- OpenJFX 14
- OpenJDK 14
- Associates a custom file type (
.pew) with this application.
- Uses the
jpackagetool from open jdk 14 to create application bundles.
- Capable of catching native apple
FILE_OPENevents when double clicking files.
- Contains separete icons for file type and application.
- In order to catch all macOS FILE_OPEN events, the
Launcherclass needed to be introduced. While it allows to catch initial events, using it and launching JavaFX over the Main method means that AWT is the main GUI toolkit. The native system menu bar on mac os is no longer supported as a consequence.
- Mime-type is set to binary files. Change
*.propertiesconfigurations to your needs.
- Windows platform not tested, yet. MacOS and Linux (Debian) are.
# run: make -B # bundle mac app: make -B jpackage_dawrin # bundle linux app: make -B jpackage_linux