From 205b849f258e85d673181f416e224fbcd1381a14 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:23:30 +0000 Subject: [PATCH] Create launcher.sh --- scripts/scripts/launcher.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 scripts/scripts/launcher.sh diff --git a/scripts/scripts/launcher.sh b/scripts/scripts/launcher.sh new file mode 100644 index 00000000..8ddd0c4b --- /dev/null +++ b/scripts/scripts/launcher.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Configuration +MIN_JAVA_VERSION="17" +PREFERRED_JAVA_VERSION="21" +JAVA_DOWNLOAD_URL="https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz" +BROWSER_OPEN="true" + +# Check Java version +if type -p java > /dev/null; then + _java=java +elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then + _java="$JAVA_HOME/bin/java" +else + echo "Java not found. Please install Java 21." + xdg-open "$JAVA_DOWNLOAD_URL" + exit 1 +fi + +version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}' | cut -d'.' -f1) +if [[ "$version" -lt "$MIN_JAVA_VERSION" ]]; then + echo "Java version $version detected. Please install Java 21." + xdg-open "$JAVA_DOWNLOAD_URL" + exit 1 +fi + +# Run application +exec java -jar "$(dirname "$0")/Stirling-PDF.jar" "$@"