Optional add-on for the Casciian text user interface
library that integrates the JDK's java.desktop module.
This project lives under code-java-desktop/ and is independent from
the main code/ project. It is published separately to Maven Central, so
applications can opt in only when they actually need it.
Casciian is designed to be runnable as a GraalVM native image, which means
the core library deliberately avoids any dependency on the
java.desktop
module — that module is large, has many platform-specific behaviors, and
is awkward to use with native-image.
However, when an application is not building a native image and runs
on a regular JVM that has full Java Desktop support, it can take
advantage of the rich functionality shipped in java.desktop — such as
javax.imageio.ImageIO for image decoding. This add-on lets users opt
into those capabilities by simply adding a single dependency. If you
don't add this dependency, your application keeps working exactly
as before, and remains compatible with native-image.
casciian-java-desktop— the add-on itself, packaged as a JPMS modulecasciian.java.desktop. It depends oncasciianand onjava.desktop. Currently it provides:casciian.javadesktop.decoders.ImageIORGBDecoder— anImageDecoderbacked byjavax.imageio.ImageIO. Out of the box it decodes PNG and JPEG files, but the constructor accepts a custom regex / description so applications can register it for any other format ImageIO supports on their JVM (BMP, GIF, WBMP, …).
demo— a small TUI application demonstrating the add-on. It registersImageIORGBDecoderonImageDecoderRegistryand lets the user pick a.png/.jpgfile fromFile ▸ Opento display it in aTImageWindow. Built as a fat JAR via thejarDemotask.
The project uses Gradle (wrapper included). At build time it uses a
Gradle composite build
to substitute the published io.github.crramirez:casciian artifact with
the sibling project under ../code, so you don't need to publish a
SNAPSHOT first to build locally:
cd code-java-desktop
./gradlew buildTo produce the demo fat JAR:
./gradlew :demo:jarDemo
java -jar demo/build/libs/casciian-java-desktop-demo-<version>.jarThe fat JAR bundles the demo, the add-on, the core casciian library and all runtime dependencies (including JLine), so it can be run standalone.
Once published, add it as a dependency alongside core casciian:
dependencies {
implementation "io.github.crramirez:casciian:<version>"
implementation "io.github.crramirez:casciian-java-desktop:<version>"
}Then, no further wiring is required: as of Casciian 1.4.2, the
ImageIORGBDecoder is registered as a
java.util.ServiceLoader
provider (declared in the add-on's module-info.java and
META-INF/services/casciian.image.decoders.ImageDecoder). It is
automatically picked up by TApplication's constructor via
ImageDecoderRegistry.getInstance().loadDecoders(), so any
casciian.TImageWindow (and any other code path going through
ImageDecoderRegistry) can open PNG and JPEG files out of the box.
If you need to customize the registered decoder (e.g. extend it to BMP or GIF), you can still register an instance manually, and it will coexist with the auto-discovered one:
ImageDecoderRegistry.getInstance()
.registerDecoder(new ImageIORGBDecoder(
"^.*\\.[gG][iI][fF]$", "GIF Image Files (*.gif)"));If you compile your application with native-image, do not add
this dependency: java.desktop and ImageIO are not available (or
require non-trivial reachability metadata). Stick to the pure-Java
decoders shipped with core casciian.
Apache License, Version 2.0. See the project LICENSE.