From d4e8c82c55d3cc0cb6a9feb897c4eecc4d68b9cb Mon Sep 17 00:00:00 2001 From: Wouter Born Date: Sat, 9 Sep 2023 16:53:42 +0200 Subject: [PATCH] Check that JVM version is 17 Aborts startup with a helpful message when the JVM version is not 17. Signed-off-by: Wouter Born --- distributions/openhab/src/main/resources/bin/karaf | 5 ++++- distributions/openhab/src/main/resources/bin/karaf.bat | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/distributions/openhab/src/main/resources/bin/karaf b/distributions/openhab/src/main/resources/bin/karaf index 58dc37c14a..1780bc283c 100755 --- a/distributions/openhab/src/main/resources/bin/karaf +++ b/distributions/openhab/src/main/resources/bin/karaf @@ -157,8 +157,11 @@ init() { # Determine the JVM vendor detectJVM - # Determine the JVM version >= 1.6 + # Determine the JVM version and check that it is version 17 checkJvmVersion + if [ "${VERSION}" -ne "17" ]; then + die "JVM must be version 17. JVM version ${VERSION} is unsupported (JAVA_HOME=$JAVA_HOME)" + fi # Check if a root instance is already running checkRootInstance diff --git a/distributions/openhab/src/main/resources/bin/karaf.bat b/distributions/openhab/src/main/resources/bin/karaf.bat index 4146c70088..e9f75b7e97 100644 --- a/distributions/openhab/src/main/resources/bin/karaf.bat +++ b/distributions/openhab/src/main/resources/bin/karaf.bat @@ -214,6 +214,11 @@ for /f tokens^=2-5^ delims^=.-_+^" %%j in ('"%JAVA%" -fullversion 2^>^&1') do ( if %%j==1 (set JAVA_VERSION=%%k) else (set JAVA_VERSION=%%j) ) +if %JAVA_VERSION% NEQ 17 ( + call :warn "JVM must be version 17. JVM version %JAVA_VERSION% is unsupported (JAVA_HOME=%JAVA_HOME%)" + goto END +) + if %JAVA_VERSION% GTR 8 ( pushd "%KARAF_HOME%\lib\jdk9plus" for %%G in (*.jar) do call:APPEND_TO_JDK9PLUS_CLASSPATH %%G