Supernaut.FX is a lightweight dependency injection framework for JavaFX applications. It is a wrapper above the core dependency injection capability of Micronaut® framework (provided by the micronaut-inject
JAR.) It enables the use of dependency injection in application, controller, and service objects.
-
JavaFX-compatible Dependency Injection
-
Main application class is dependency-injected
-
JavaFX FXML controllers are dependency-injected
-
Service object dependency injection
-
-
Your main application class need not extend
javafx.application.Application
-
BrowserService
abstraction for opening links in Web Browser (abstraction of JavaFXHostServices
)- Simple
-
Supernaut.FX aspires to be a component library for your application with the sole concern of enabling dependency injection.
- Modern
-
Supernaut.Fx is designed for modern JavaFX applications that use the latest version of JavaFX (currently 17) and are built for distribution using either the jpackage tool of JDK 17 or as native images using GraalVM JDK 11 (using native-image and Gluon Substrate)
- Lightweight
-
Supernaut.FX introduces no new dependencies beyond what is required for JavaFX and the
micronaut-inject
component of Micronaut® framework.
See the Getting Started section in the Supernaut.FX User’s Guide.
Supernaut.FX JavaDoc is available on GitHub Pages.
Although the API may change, binary packages are available on GitLab.com. You can download JARs or use the provided Maven coordinates to link to them directly from your pom.xml
or build.gradle
.
To access our GitLab Maven repository, add the following to your pom.xml
:
<repositories>
<repository>
<id>gitlab-supernaut-maven</id>
<url>https://gitlab.com/api/v4/projects/26584840/packages/maven</url>
</repository>
</repositories>
See the Maven sample application for the details of setting up your pom.xml
.
To access our GitLab Maven repository, add the following to the repositories
section of your build.gradle
:
maven {
url 'https://gitlab.com/api/v4/projects/26584840/packages/maven'
}
See the Gradle sample application for the details of setting up your build.gradle
.
Supernaut.FX currently consists of 3 Java modules (JARs)
Module name | Purpose | Dependencies |
---|---|---|
Interfaces for background components (no JavaFX) |
No dependencies! |
|
JavaFX application dependency injection support |
|
|
App Launcher with dependency injection provided by Micronaut framework |
|
Typical applications will have a compile-time dependency on app.supernaut.fx
and a runtime dependency on app.supernaut.fx.micronaut
.
You may also develop library modules for services depending only on app.supernaut
.
-
Clone the repository
-
Make sure your
JAVA_HOME
points to a JDK 17 or newer -
./gradlew -PbaseModuleJavaCompatibility=8 buildCI buildJPackages
To test one of the included sample apps:
-
Run the sample Hello app
-
./gradlew :apps:supernaut-fx-sample-hello:run
-
-
Build a
jpackage
-ed Hello app-
./gradlew :apps:supernaut-fx-sample-hello:jpackage
-
Open the
apps/supernaut-fx-sample-hello/build/jpackage
directory and launch the native application for your platform
-
Supernaut.FX was inspired by two existing JavaFX DI frameworks, but is focused on JavaFX 11 and later, Java Module System, jlink
, jpackage
, and Micronaut framework. Thanks Adam Bien and Gluon for the inspiration.
-
Adam Bien’s afterburner.fx
We have researched existing JavaFX frameworks and haven’t found anything that seems well-suited for the following criteria:
-
Simple
-
Minimizes abstraction and inheritance
-
Avoids imposing architectural patterns (as much as possible with DI)
-
Try to be more of a library than a framework
-
-
Fast application launch
-
Provides support for compile-time dependency injection (e.g. via Micronaut framework)
-
Initial releases are for Micronaut framework only
-
Possibly in the future could use an abstraction to allow other similar DI frameworks (help wanted with this issue)
-
-
Designed for Java apps shipped with a bundled runtime
-
Applications built with JDK 17+ jpackage
-
Applications built with GraalVM and Gluon Substrate
-
-
Aggressively tracks the latest JDK and JavaFX, recent Android versions
-
JDK 11 or later for JavaFX components
-
JDK 9 (maybe JDK 8 multi-release JARs?) for base interfaces and possible Android support
-
-
Minimal dependencies, minimal transitive dependencies
-
Core components in pure Java (no additional language runtime libraries)
-
Keep packaged/bundled apps as small as possible
-
Minimal dependencies simplifies security review
-
Potential for use by other frameworks
-
-
Compatible with Ahead-of-Time Compile tools
-
Avoids use of dynamic runtime features
-
Support popular Ahead-of-Time (AOT) compilation platforms
-
Android
-
-
-
Support for first-class native-looking apps (via optional, add-on components)
-
Follows each platform’s UI guidelines
-
First-class platform integration
-
macOS integration
-
Support for App Sandbox and Mac App Store
-
Native-looking macOS Menu Bar Menus (with help from NSMenuFX)
-
Integration with Apple’s unified logging system.
-
-
May use additional libraries (e.g. NSMenuFX) on a specific platform
-
-
Non-goal: reusable UI on desktop and mobile
-
Android apps have option to use custom UI written with Android SDK
-
iOS should have option to use UIKit
-