Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

Boilerplate recognising .pew files.

# 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:

Boilerplate recognising .pew files.

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
```