openHABian will install the default, Temurin 21. If you want a different JRE for what ever reason, would use Menu 45.
When you change the version of OH to install (though Menu 41)(openhabian/functions/menu.bash at 40e088cf306b17038a6184796868cbbfa34e2097 ¡ openhab/openhabian ¡ GitHub), it executes this function. You can see here that if the version of OH is 5, it changes the default jre and installs Temeruin21 if itâs not already installed automatically as part of changing the version of OH.
The full code is posted below so you donât have to jump around multiple files.
Menu 41:
case "$choice2" in
41\ *) openhab_setup "release";;
*openHAB\ Milestone) openhab_setup "milestone";;
*openHAB\ Snapshot) openhab_setup "snapshot";;
42\ *) openhab_shell_interfaces;;
43\ *) openhab_clean_cache;;
44\ *) nginx_setup;;
*OpenJDK\ 17) update_config_java "17" && java_install "17";;
*OpenJDK\ 21) update_config_java "21" && java_install "21";;
*Temurin\ 17) update_config_java "Temurin17" && java_install "Temurin17";;
*Temurin\ 21) update_config_java "Temurin21" && java_install "Temurin21";;
*OpenJDK\ 11) update_config_java "11" && java_install "11";;
46\ *) jsscripting_npm_install "openhab";;
*Uninstall\ openhab-js) jsscripting_npm_install "openhab" "uninstall";;
47\ *) jsscripting_npm_install "openhab_rules_tools";;
*Uninstall\ openhab_rules_tools) jsscripting_npm_install "openhab_rules_tools" "uninstall";;
"") return 0 ;;
*) whiptail --msgbox "An unsupported option was selected (probably a programming error):\\n \"$choice2\"" 8 80 ;;
esac
openhab_setup()
## Function to install / upgrade / downgrade the installed openHAB version
## Valid argument 1: "release", "milestone" or "testing", or "snapshot" or "unstable"
## Valid argument 2 (optional): Linux package name to install
##
## openhab_setup(String release)
##
openhab_setup() {
local introText
local keyName="openhab"
local openhabVersion
local installVersion
local repo
local successText
local noJVMText="We were unable to install/upgrade your system to openHAB 5.\\nThis requires Java version 21, and we have been unable to identify and install a suitable Java JVM package for your hardware-OS combo."
local ohPkgName="openhab"
local textsize=9
if [[ $1 == "snapshot" || $1 == "unstable" ]]; then
introText="Proceed with caution!\\n\\nYou are about to switch over to the latest $ohPkgName unstable snapshot build. The daily snapshot builds contain the latest features and improvements but might also suffer from bugs or incompatibilities. Please be sure to take a full openHAB configuration backup first!\\n\\nBeware that downgrading will not be possible, you can only re-install old software and re-important the config backup you should have made before the upgrade."
successText="The latest unstable snapshot build of $ohPkgName is now running on your system.\\n\\nPlease test the correct behavior of your setup. You might need to adapt your configuration, if available. If you made changes to the files in '/var/lib/${ohPkgName}' they were replaced, but you can restore them from backup files next to the originals.\\n\\nIf you find any problems or bugs, please report them and state the snapshot version you are on. To stay up-to-date with improvements and bug fixes you should upgrade your packages (using menu option 02) regularly."
repo="deb [signed-by=/usr/share/keyrings/${keyName}.gpg] https://openhab.jfrog.io/artifactory/openhab-linuxpkg unstable main"
echo -n "$(timestamp) [openHABian] Beginning install of latest $ohPkgName snapshot build (unstable repo)... "
elif [[ $1 == "release" || $1 == "stable" ]]; then
introText="You are about to install or change to the latest stable $ohPkgName release.\\n\\nPlease be aware that downgrading from a newer unstable snapshot build is not supported. Please consult with the documentation or community forum and be sure to take a full openHAB configuration backup first!"
successText="The stable release of $ohPkgName is now installed on your system.\\n\\nPlease test the correct behavior of your setup. You might need to adapt your configuration, if available. If you made changes to the files in '/var/lib/${ohPkgName}' they were replaced, but you can restore them from backup files next to the originals.\\n\\nCheck the \"openHAB Release Notes\" and the official announcements to learn about additons, fixes and changes."
repo="deb [signed-by=/usr/share/keyrings/${keyName}.gpg] https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable main"
echo -n "$(timestamp) [openHABian] Beginning install of latest $ohPkgName release (stable repo)... "
elif [[ $1 == "milestone" || $1 == "testing" ]]; then
introText="You are about to install or change to the latest milestone $ohPkgName build. Note this is openHAB 5!\\n\\nMilestones contain the latest features and is supposed to run stable, but if you experience bugs or incompatibilities, please help with enhancing openHAB by posting them on the community forum or by raising a GitHub issue in the proper place.\\n\\nPlease be aware that downgrading from a newer build is not supported!\\n\\nPlease consult with the documentation or community forum and be sure to take a full openHAB configuration backup first!"
successText="The testing release of $ohPkgName is now installed on your system.\\n\\nPlease test the correct behavior of your setup. You might need to adapt your configuration, if available. If you made changes to the files in '/var/lib/${ohPkgName}' they were replaced, but you can restore them from backup files next to the originals.\\n\\nCheck the \"openHAB Release Notes\" and the official announcements to learn about additons, fixes and changes."
repo="deb [signed-by=/usr/share/keyrings/${keyName}.gpg] https://openhab.jfrog.io/artifactory/openhab-linuxpkg testing main"
echo -n "$(timestamp) [openHABian] Beginning install of latest $ohPkgName milestone build (testing repo)... "
fi
if [[ -n $INTERACTIVE ]]; then
if (whiptail --title "openHAB software change" --yes-button "Continue" --no-button "Cancel" --yesno "$introText" 20 80); then echo "OK"; else echo "CANCELED"; return 1; fi
export DEBIAN_FRONTEND=noninteractive
else
echo "OK"
fi
# date needs to be > Apr 1, 24 for openhab repo signing key to be valid
# note RPis have no real time clock
if [[ $(date +%y%m%d) -lt 240401 ]]; then
systemctl stop systemd-timesyncd
timedatectl set-time "2024-04-09 00:00:00"
systemctl start systemd-timesyncd
fi
if running_in_docker || [[ -z $OFFLINE ]]; then
if ! add_keys "https://openhab.jfrog.io/artifactory/api/gpg/key/public" "$keyName"; then return 1; fi
rm -f /etc/apt/sources.list.d/openhab*.list
echo "$repo" > /etc/apt/sources.list.d/openhab.list
dpkg --configure -a --force-confnew
echo -n "$(timestamp) [openHABian] Installing openHAB... "
if ! apt-get clean --yes -o DPkg::Lock::Timeout="$APTTIMEOUT"; then echo "FAILED (apt cache clean)"; return 1; fi
cond_redirect apt-get update -o DPkg::Lock::Timeout="$APTTIMEOUT"
openhabVersion="${2:-$(apt-cache madison ${ohPkgName} | head -n 1 | awk '{ print $3 }')}"
openhabMajorVersion="$(echo "$openhabVersion" | cut -d'.' -f1)"
javaVersion="$(java -version |& head -1 | awk -F'"' '{ print $2 }' | cut -d '.' -f1)"
if [[ $openhabMajorVersion = 4 ]]; then
if [[ $javaVersion -lt 17 ]] ; then
update_config_java "17"
java_install "17"
fi
elif [[ $openhabMajorVersion = 5 ]]; then
if [[ $javaVersion -lt 21 ]] ; then
update_config_java "Temurin21"
java_install "Temurin21"
fi
fi
javaVersionNeu="$(java -version |& head -1 | awk -F'"' '{ print $2 }' | cut -d '.' -f1)"
if [[ $openhabMajorVersion = 5 ]] && [[ $javaVersionNeu -lt 21 ]] ; then
echo "FAILED (could not install required Java 21)"
if [[ -n $INTERACTIVE ]]; then
unset DEBIAN_FRONTEND
if is_arm && [[ "$(getconf LONG_BIT)" == "32" ]]; then
noJVMText+="\\n\\nThere is currently no suitable JVM package for ARM processors that works\\nwith a 32 bit OS image."
textsize=12
fi
whiptail --title "Operation failed!" --msgbox "$noJVMText" ${textsize} 80
fi
return 1
fi
if [[ -n $openhabVersion ]]; then
installVersion="${ohPkgName}=${openhabVersion} ${ohPkgName}-addons=${openhabVersion}"
else
installVersion="${ohPkgName} ${ohPkgName}-addons"
fi
# shellcheck disable=SC2086
if cond_redirect apt-get install --allow-downgrades --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" --option Dpkg::Options::="--force-confnew" $installVersion; then echo "OK"; else echo "FAILED"; return 1; fi
else
echo -n "$(timestamp) [openHABian] Installing cached openHAB version... "
if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" --option Dpkg::Options::="--force-confnew" ${ohPkgName} ${ohPkgName}-addons; then echo "OK"; else echo "FAILED"; return 1; fi
fi
# shellcheck disable=SC2154
gid="$(id -g "$username")"
cond_redirect usermod -g "openhab" "$username" &> /dev/null
cond_redirect usermod -aG "$gid" "$username" &> /dev/null
echo -n "$(timestamp) [openHABian] Setting up openHAB service... "
if ! cond_redirect zram_dependency install ${ohPkgName}; then return 1; fi
if ! cond_redirect systemctl -q daemon-reload; then echo "FAILED (reload)"; return 1; fi
if cond_redirect systemctl enable --now ${ohPkgName}.service; then echo "OK"; else echo "FAILED (enable service)"; return 1; fi
openhab_misc
create_systemd_dependencies
dashboard_add_tile "openhabiandocs"
if [[ -n $INTERACTIVE ]]; then
unset DEBIAN_FRONTEND
whiptail --title "Operation successful!" --msgbox "$successText" 15 80
fi
}
update_copnfig_java()
## Update requested version of Java in '$configFile'.
## Valid arguments: "11", "17"
##
## update_config_java(String type)
##
update_config_java() {
if ! cond_redirect sed -i -e 's|^java_opt.*$|java_opt='"${1}"'|' "$configFile"; then return 1; fi
source "$configFile"
}
java_install()
## Install Java version from dpkg repositories dynamically.
## This function is a wrapper for the OpenJDK and Adoptium Eclipse Temurin JDK install functions.
## Valid arguments: "17", "21", "Temurin17", "Temurin21", 11 (legacy)
##
## java_install(String version)
##
java_install() {
if openhab_is_running; then
cond_redirect systemctl stop openhab.service
fi
if [[ -d /opt/jdk ]]; then
java_alternatives_reset
rm -rf /opt/jdk
fi
if [[ $1 == Temurin* ]]; then
adoptium_install_apt "${1/Temurin/}"
else
openjdk_install_apt "$1"
fi
if openhab_is_installed; then
cond_redirect systemctl restart openhab.service
fi
}
Note that update_java_config
and java_install
will also get called from the scripts called by menu 45 and they also get called when doing an upgrade if there is no Java already installed. For the system upgrade, the version defaults to Temerun21
In openHABian you only need to install Java 21 separately if you want a JRE different from Temurin21. Otherwise Java 17 will upgrade to Java 21 Temurin automatically.
And this is as it should be. The whole point of openHABian is the end users shouldnât have to worry about this stuff unless they want to. If one chooses to upgrade to OH 5, and the OS can handle it, all the dependencies also get installed which, in this case, is Java 21.