- Java SDK 9 Early Access (or later)
- IntelliJ IDEA 2017.1 (or later with support for Java 9 modules)
- Maven 3 (maven-compiler-plugin v3.6.2 support for compiling java 9 modules)
- JavaFX with Java 9
- Puddle A thread-safe lightweight standalone Java JDBC connection pool manager that I wrote.
- SQLite-native (as backend db, native x86_64 binary libs included in below driver)
- Forked Xerial SQLite JDBC Driver (v3.20.0) with support for encryption (SQLCipher)
This demo application is built to show you how you can structure your desktop JavaFX app similar to the Robotlegs approach. The structure in this app is highly inspired by Yennick Trevels blog post with using direct calls with interfaces over events because that makes it easier to follow the flow of your application. However this example does not use any dependency injection framework such as guice since I wanted to keep it as pure Java 9 as possible for instructional purposes. This app is also built with the new module approach in Java 9. The UI is built with pure Java code instead of using fxml since I prefer it that way giving me more control over my code. Also the UI is built to be resizable meaning the UI-components adapt their size when the main application windows is being resized.
SQLite with Forked Xerial SQLite JDBC Driver (v3.20.0) with support for encryption (SQLCipher) is used as a backend with pure JDBC-calls for instructional purpose. The driver has native binary libs (dll, jnilib, so) included for 64-bit Windows x86_64, MacOSX x86_64 and Linux x86_64 platforms.
The application creates and populates an encrypted JavaFx-structure-demo.db file under the user home directory, System.getProperty("user.home").
- MacOS
/Users/username/JavaFx-structure-demo.db
- Windows
C:\Users\username\JavaFx-structure-demo.db
- Linux
/home/username/JavaFx-structure-demo.db
- compile with Java 9 SDK
- run with:
java -m com.example/com.example.Main
Build artifacts (jars) from the modules. From within Intellij choose Build->Build Artifacts...
Now the following two jars should have been created under the target folder:
- JavaFx-strucure-demo.jar (including a MANIFEST.MF-file containing "Main-Class: com.example.Main")
- sqlite-jdbc.jar
Run the following jlink command from the target catalog
- MacOS (61 MB)
jlink --output release/JavaFx-structure-demo --compress=2 --module-path="JavaFx-structure-demo.jar:sqlite-jdbc.jar:/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/jmods" --add-modules com.example,sqlite.jdbc
- Windows (59 MB)
jlink --output release/JavaFx-structure-demo --compress=2 --module-path="JavaFx-structure-demo.jar;sqlite-jdbc.jar;C:\Program Files\Java\jdk-9\jmods" --add-modules com.example,sqlite.jdbc
- Linux (72 MB)
jlink --output release/JavaFx-structure-demo --compress=2 --module-path="JavaFx-structure-demo.jar:sqlite-jdbc.jar:/opt/jdk-9/jmods" --add-modules com.example,sqlite.jdbc
Usage:
From the release/JavaFx-structure-demo/bin folder run:
- MacOS/Linux
./java -m com.example/com.example.Main
- Windows
.\javaw -m com.example/com.example.Main


