diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index a85b12b..70de76e 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -25,7 +25,7 @@ jobs:
- name: Make staging directory
run: mkdir staging
- name: Copy JAR to staging
- run: cp target/distribution/* staging
+ run: cp -r target/distribution/* staging
- name: Upload
uses: actions/upload-artifact@v2
with:
diff --git a/.gitignore b/.gitignore
index 2d513a0..2a8f6e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
/.idea/
/target/
+/*.iml
+download/
diff --git a/README.md b/README.md
index ce1e066..7f088c5 100644
--- a/README.md
+++ b/README.md
@@ -26,29 +26,47 @@ dependency comes pre-installed on recent Raspbian images. However, you can also
download and install it yourself using the instructions found
[here](http://abyz.me.uk/rpi/pigpio/download.html).
+As this application has a JavaFX user interface, the project requires the OpenJFX runtime. When the package is build,
+then the runtime is downloaded and added to the distribution directory.
+
## BUILD DEPENDENCIES & INSTRUCTIONS
-This project can be built with [Apache Maven](https://maven.apache.org/) 3.6
-(or later) and Java 11 OpenJDK (or later). These prerequisites must be installed
-prior to building this project. The following command can be used to download
-all project dependencies and compile the Java module. You can build this
-project directly on a Raspberry Pi with Java 11+.
+This project can be built with [Apache Maven](https://maven.apache.org/) 3.6 (or later) and Java 17 OpenJDK (or later).
+These prerequisites must be installed prior to building this project. The following command can be used to download all
+project dependencies and compile the Java module. You can build this project directly on a Raspberry Pi with Java 17+.
-```
+```bash
mvn clean package
```
### Compiled application to run on the Raspberry Pi
-Once the build is complete and was successful, you can find the compiled
-artifacts in the `target` folder. Specifically
-all dependency modules (JARs) and a simple `run.sh` bash script will be located in the
-`target/distribution`.
+Once the build is complete and was successful, you can find the compiled artifacts in the `target` folder. Specifically
+all dependency modules (JARs) and a simple `run.sh` bash script will be located in the `target/distribution` folder.
+This folder contains all the required files needed to distribute (copy) to your Raspberry Pi to run this project.
+
+For your convenience, this `distribution` folder is zipped up, and is also located in the `target/` folder. Copy this
+file to your Raspberry Pi, for example with the following command:
+
+```bash
+rsync target/pi4j-example-fxgl-0.0.1.zip pi@192.8.0.124:.
+```
+
+Then on the Raspberry Pi unzip the file with the following command:
+
+```bash
+unzip pi4j-example-fxgl-0.0.1.zip
+```
-These are all the required files needed to distribute (copy) to your
-Raspberry Pi to run this project. If you are using the native bindings running
-locally on the Raspberry Pi, then you make have to run the program using `sudo`
-to gain the necessary access permissions to the hardware I/O.
+Now the example can be started with the following command:
+
+```bash
+cd pi4j-example-fxgl-0.0.1/
+./run.sh
+```
+
+*Note:* If you are using the native bindings running locally on the Raspberry Pi, then you may have to run the program
+using `sudo` to gain the necessary access permissions to the hardware I/O.
This is the list of files created by the build process of this example application:
@@ -59,15 +77,10 @@ This is the list of files created by the build process of this example applicati
* pi4j-plugin-raspberrypi
* slf4j-api
* slf4j-simple
+* javafx-*
+* and additional dependencies required for JavaFX and FXGL
* run.sh --> this is the actual start file which will run pi4j-example-javafx
-Make the run script executable and start it like this:
-
-```
-chmod +x run.sh
-sudo ./run.sh
-```
-
## LICENSE
Pi4J Version 2.0 and later is licensed under the Apache License,
diff --git a/assets/run-kiosk.sh b/assets/run-kiosk.sh
index db565cf..265e5e1 100644
--- a/assets/run-kiosk.sh
+++ b/assets/run-kiosk.sh
@@ -1,15 +1,16 @@
#!/usr/bin/env bash
/sbin/init 3
export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true
+declare SCRIPT_DIR="$(cd "${0%/*}" ; pwd)"
java \
-Degl.displayid=/dev/dri/card0 \
-Dmonocle.egl.lib=/opt/javafx-sdk-17/lib/libgluon_drm-1.1.3.so \
- -Djava.library.path=/opt/javafx-sdk-17/lib \
+ -Djava.library.path="${SCRIPT_DIR}/openjfx/lib" \
-Dmonocle.platform.traceConfig=false \
-Dprism.verbose=false \
-Djavafx.verbose=false \
-Dmonocle.platform=EGL \
- --module-path .:/opt/javafx-sdk-17/lib \
+ --module-path ".:${SCRIPT_DIR}/openjfx/lib" \
--add-modules javafx.controls \
--module com.pi4j.example/com.pi4j.example.JavaFxExample $@
/sbin/init 5
diff --git a/assets/run.sh b/assets/run.sh
index 0ce4e19..c5de0f9 100644
--- a/assets/run.sh
+++ b/assets/run.sh
@@ -1,10 +1,11 @@
#!/usr/bin/env bash
+declare SCRIPT_DIR="$(cd "${0%/*}" ; pwd)"
java \
-Dglass.platform=gtk \
- -Djava.library.path=/opt/javafx-sdk-17/lib \
+ -Djava.library.path="${SCRIPT_DIR}/openjfx/lib" \
-Dmonocle.platform.traceConfig=false \
-Dprism.verbose=false \
-Djavafx.verbose=false \
- --module-path .:/opt/javafx-sdk-17/lib \
+ --module-path ".:${SCRIPT_DIR}/openjfx/lib" \
--add-modules javafx.controls \
--module com.pi4j.example/com.pi4j.example.JavaFxExample $@
diff --git a/download_openjfx.bat b/download_openjfx.bat
new file mode 100644
index 0000000..fb37973
--- /dev/null
+++ b/download_openjfx.bat
@@ -0,0 +1,62 @@
+@echo off
+
+REM Variables
+set URL="https://download2.gluonhq.com/openjfx/22/openjfx-22_linux-aarch64_bin-sdk.zip"
+set SHA_URL="https://download2.gluonhq.com/openjfx/22/openjfx-22_linux-aarch64_bin-sdk.zip.sha256"
+set TARGET_DIR="target\openjfx"
+set SUBDIR="extracted_files"
+set TEMP_DIR="%TEMP%\openjfx_temp"
+
+REM Function to calculate SHA256 sum
+:calculate_sha256
+certutil -hashfile "%1" SHA256 | findstr /R "[0-9a-fA-F]*"
+
+REM Create target directory
+rmdir /s /q "%TARGET_DIR%\%SUBDIR%"
+mkdir "%TARGET_DIR%\%SUBDIR%" 2>nul
+
+REM Download the file if not already downloaded
+if not exist "%TARGET_DIR%\%~n0" (
+ echo Downloading %URL%...
+ bitsadmin.exe /transfer myDownloadJob /download /priority normal %URL% "%TARGET_DIR%\%~n0"
+) else (
+ echo File already exists. Skipping download.
+)
+
+REM Download the SHA256 file if not already downloaded
+if not exist "%TARGET_DIR%\%~n1" (
+ echo Downloading SHA256 checksum file...
+ bitsadmin.exe /transfer mySHA256Job /download /priority normal %SHA_URL% "%TARGET_DIR%\%~n1"
+)
+
+REM Verify the SHA256 sum
+echo Verifying SHA256 sum...
+for /f "tokens=*" %%a in ('type "%TARGET_DIR%\%~n1"') do set "sha256sum=%%a"
+for /f "tokens=*" %%b in ('call :calculate_sha256 "%TARGET_DIR%\%~n0"') do (
+ if "%%b"=="%sha256sum%" (
+ echo SHA256 sum verified successfully.
+ ) else (
+ echo SHA256 sum verification failed.
+ rmdir /s /q "%TEMP_DIR%"
+ exit /b 1
+ )
+)
+
+REM Extract the zip file
+echo Extracting the zip file...
+powershell -noprofile -command "& {Add-Type -A 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('%TARGET_DIR%\%~n0', '%TARGET_DIR%\%SUBDIR%')}"
+
+rem Find the folder and rename it
+for /f "delims=" %%D in ('dir /b /ad "%TARGET_DIR%\%SUBDIR%"') do (
+ set "folder=%%~fD"
+ goto :rename
+)
+:rename
+if defined folder (
+ ren "%folder%" new_name
+ echo Folder renamed successfully.
+) else (
+ echo Folder not found.
+)
+
+echo Extraction completed. Files are located in: %TARGET_DIR%\%SUBDIR%
diff --git a/download_openjfx.sh b/download_openjfx.sh
new file mode 100755
index 0000000..5360d46
--- /dev/null
+++ b/download_openjfx.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# Variables
+URL="https://download2.gluonhq.com/openjfx/22/openjfx-22_linux-aarch64_bin-sdk.zip"
+SHA_URL="https://download2.gluonhq.com/openjfx/22/openjfx-22_linux-aarch64_bin-sdk.zip.sha256"
+TARGET_DIR="download/openjfx"
+SUBDIR="extracted_files"
+TEMP_DIR=$(mktemp -d)
+
+# Function to calculate SHA256 sum
+calculate_sha256() {
+ sha256sum "$1" | awk '{print $1}'
+}
+
+# Create target directory if it doesn't exist
+rm -rf "${TARGET_DIR:?}/$SUBDIR"
+mkdir -p "$TARGET_DIR/$SUBDIR"
+
+# Download the file if not already downloaded
+if [ ! -f "$TARGET_DIR/$(basename "$URL")" ]; then
+ echo "Downloading $URL..."
+ wget -q --show-progress -O "$TARGET_DIR/$(basename "$URL")" "$URL"
+else
+ echo "File already exists. Skipping download."
+fi
+
+# Download the SHA256 file if not already downloaded
+if [ ! -f "$TARGET_DIR/$(basename "$SHA_URL")" ]; then
+ echo "Downloading SHA256 checksum file..."
+ wget -q -O "$TARGET_DIR/$(basename "$SHA_URL")" "$SHA_URL"
+fi
+
+# Verify the SHA256 sum
+echo "Verifying SHA256 sum..."
+if [ "$(calculate_sha256 "$TARGET_DIR/$(basename "$URL")")" == "$(cut -d ' ' -f1 "$TARGET_DIR/$(basename "$SHA_URL")")" ]; then
+ echo "SHA256 sum verified successfully."
+else
+ echo "SHA256 sum verification failed."
+ rm -rf "$TEMP_DIR"
+ exit 1
+fi
+
+# Extract the zip file
+echo "Extracting the zip file..."
+unzip -q "$TARGET_DIR/$(basename "$URL")" -d "$TARGET_DIR/$SUBDIR"
+
+# Find the folder and rename it
+folder=$(find "$TARGET_DIR/$SUBDIR" -maxdepth 1 -mindepth 1 -type d -exec echo {} \;)
+if [ -n "$folder" ]; then
+ mv "$folder" "$TARGET_DIR/$SUBDIR/openjfx"
+fi
+
+echo "Extraction completed. Files are located in: $TARGET_DIR/$SUBDIR"
diff --git a/pom.xml b/pom.xml
index 59542c5..1c23be6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -120,15 +120,28 @@
maven-antrun-plugin
- 1.8
+ 3.1.0
+
copy
package
+
+
+
+
+
+
+
+
+
-
+
+
+
+
@@ -138,6 +151,13 @@
+
+
+ org.apache.ant
+ ant
+ 1.10.11
+
+
@@ -162,11 +182,31 @@
On the Raspberry Pi we use specific JavaFX dependencies,
so we exclude them here and they are added in the run-script.
-->
- org.openjfx
+
+ linux,win,mac
+
+ maven-assembly-plugin
+
+ false
+
+ src/assembly/assembly.xml
+
+
+
+
+ all
+ package
+
+ single
+
+
+
+
+
diff --git a/src/assembly/assembly.xml b/src/assembly/assembly.xml
new file mode 100644
index 0000000..c734e0e
--- /dev/null
+++ b/src/assembly/assembly.xml
@@ -0,0 +1,16 @@
+
+ bin
+
+ zip
+
+
+
+
+ ${project.build.directory}/distribution
+
+ false
+
+
+
+
\ No newline at end of file