Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eschmar/javafx-custom-file-ext-boilerplate
JavaFX Custom File Extension Viewer boilerplate
https://github.com/eschmar/javafx-custom-file-ext-boilerplate
boilerplate custom-file-type gradle java java-14 java-18 java-21 java-module java-modules javafx jpackage
Last synced: about 2 months ago
JSON representation
JavaFX Custom File Extension Viewer boilerplate
- Host: GitHub
- URL: https://github.com/eschmar/javafx-custom-file-ext-boilerplate
- Owner: eschmar
- License: mit
- Created: 2019-08-04T15:47:16.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-06T09:52:05.000Z (over 1 year ago)
- Last Synced: 2023-10-06T10:36:10.635Z (over 1 year ago)
- Topics: boilerplate, custom-file-type, gradle, java, java-14, java-18, java-21, java-module, java-modules, javafx, jpackage
- Language: Java
- Homepage: https://eschmann.dev/posts/javafx-mac-os-custom-file-type-jpackage
- Size: 793 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://eschmann.dev/posts/javafx-mac-os-custom-file-type-jpackage/). In this example, the application is set up to handle `.pew` files with the bundle identifier `com.example.pew`. The `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](https://github.com/eschmar/javafx-custom-file-ext-boilerplate/actions) to check out.
## Requirements
* OpenJFX 21
* OpenJDK 20,21
* Gradle 8.4## Features
* Associates a custom file type (`.pew`) with this application.
* Uses the `jpackage` tool from open jdk 21 to create application bundles.
* Capable of catching native apple `FILE_OPEN` events when double-clicking files.
* Contains separate icons for file type and application.## Caveats
* In order to catch all macOS FILE_OPEN events, the `Launcher` class 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 `*.properties` configurations to your needs.
* Windows platform not tested, yet. MacOS and Linux (Debian) are.## Usage
```sh
# run:
make -B# bundle mac app:
make -B jpackage_darwin# bundle linux app:
make -B jpackage_linux
```