Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 21 for 32-bit: Add BellSoft Liberica JDK 21 #1902

Merged
merged 3 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Choose yours based on your hardware and primary use case. Please be aware that y
Use the 64 bit image versions but please be aware that 64 bit always has one major drawback: increased memory usage. That is not a good idea on heavily memory constrained platforms like Raspberries. If you want to go with 64 bit, ensure your RPi has a minimum of 2 GB, 4 will put you on the safe side.
You can use the 32 bit version for older or non official addons that will not work on 64 bit yet.
Note there's a known issue on 32 bit, JS rules are reported to be annoyingly slow on first startup and in some Blockly use cases.
If you consider using the (newer but still experimental) Java version 21, choose 64 bit. Java 21 is not available for 32 bit systems.
If you consider using the (newer but still experimental) Java version 21, if possible choose 64 bit.

On x86 hardware, it's all 64 bit but that in turn once more increases memory usage. A NUC to run on should have no less than 8 GB.

Expand Down
39 changes: 39 additions & 0 deletions functions/java-jre.bash
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,43 @@ openjdk_install_apt() {
fi
}

## Fetch BellSoft Liberica JDK using APT repository.
##
## liberica_fetch_apt()
##
liberica_fetch_apt() {
local pkgname="bellsoft-java21-lite"
if ! apt-cache show $pkgname &> /dev/null; then
ecdye marked this conversation as resolved.
Show resolved Hide resolved
local keyName="bellsoft_liberica"

if ! add_keys "https://download.bell-sw.com/pki/GPG-KEY-bellsoft" "$keyName"; then return 1; fi

echo -n "$(timestamp) [openHABian] Adding BellSoft repository to apt... "

# architectures available: amd64, i386, arm64, armhf; those could be added to the repo string via [arch=...]
if ! echo "deb [signed-by=/usr/share/keyrings/${keyName}.gpg] https://apt.bell-sw.com/ stable main" > /etc/apt/sources.list.d/bellsoft.list; then echo "FAILED"; return 1; fi
if cond_redirect apt-get update; then echo "OK"; else echo "FAILED (update apt lists)"; return 1; fi
fi
}

## Install BellSoft Liberica JDK using APT repository.
##
## liberica_install_apt()
##
liberica_install_apt() {
local pkgname="bellsoft-java21-lite"
if ! dpkg -s $pkgname &> /dev/null; then # Check if already is installed
liberica_fetch_apt
echo -n "$(timestamp) [openHABian] Installing BellSoft Liberica JDK... "
if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" $pkgname; then echo "OK"; else echo "FAILED"; return 1; fi
elif dpkg -s $pkgname &> /dev/null; then
echo -n "$(timestamp) [openHABian] Reconfiguring BellSoft Liberica JDK... "
if cond_redirect dpkg-reconfigure $pkgname; then echo "OK"; else echo "FAILED"; return 1; fi
# shellcheck disable=SC2012
update-alternatives --set java "$(ls -d /usr/lib/jvm/bellsoft-java21-lite-* | head -n1)"/bin/java
fi
}

# LEGACY SECTION

## Install appropriate Java version based on current choice.
Expand Down Expand Up @@ -117,6 +154,8 @@ java_install_or_update() {
fi
fi
fi
elif [[ $1 == "BellSoft21" ]]; then
liberica_install_apt
else # Default to 32-bit installation
if cond_redirect java_zulu_update_available "Zulu11-32"; then
java_zulu_prerequisite "Zulu11-32"
Expand Down
4 changes: 3 additions & 1 deletion functions/menu.bash
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ show_main_menu() {
" | OpenJDK 11" "Install and activate OpenJDK 11 as Java provider" \
" | Zulu 11 OpenJDK 32-bit" "Install Zulu 11 32-bit OpenJDK as Java provider" \
" | Zulu 11 OpenJDK 64-bit" "Install Zulu 11 64-bit OpenJDK as Java provider" \
" | Zulu 21 OpenJDK 64-bit" "Install Zulu 21 64-bit OpenJDK (EXPERIMENTAL)" \
" | Zulu 21 OpenJDK 64-bit" "Install Zulu 21 64-bit OpenJDK as Java provider" \
" | BellSoft Liberica JDK 21" "Install BellSoft Liberica JDK 21, supports 32bit RPi (EXPERIMENTAL)" \
"47 | Install openhab-js" "JS Scripting: Upgrade to latest version of openHAB JavaScript library (advanced)" \
" | Uninstall openhab-js" "JS Scripting: Switch back to included version of openHAB JavaScript library" \
"48 | Install openhab_rules_tools" "JS Scripting: Manually install openhab_rules_tools (auto-installed)" \
Expand All @@ -239,6 +240,7 @@ show_main_menu() {
*Zulu\ 11\ OpenJDK\ 32-bit) update_config_java "Zulu11-32" && java_install_or_update "Zulu11-32";;
*Zulu\ 11\ OpenJDK\ 64-bit) update_config_java "Zulu11-64" && java_install_or_update "Zulu11-64";;
*Zulu\ 21\ OpenJDK\ 64-bit) update_config_java "Zulu21-64" && java_install_or_update "Zulu21-64";;
*BellSoft\ Liberica\ JDK\ 21) update_config_java "BellSoft21" && java_install_or_update "BellSoft21";;
47\ *) jsscripting_npm_install "openhab";;
*Uninstall\ openhab-js) jsscripting_npm_install "openhab" "uninstall";;
48\ *) jsscripting_npm_install "openhab_rules_tools";;
Expand Down
Loading