From dd0225bdde303cc739fed60c9aff28b63b868997 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Fri, 10 Jul 2026 22:47:39 +0200 Subject: We migrate to JDK 17 This is a hard requirement to be able to migrate to a more recent jetty version, which may happen sometime soon. --- .github/workflows/ant-build-pull-request.yaml | 4 ++-- .github/workflows/ant-build.yaml | 4 ++-- README.md | 4 ++-- build.nsi | 15 +++++++++------ build.properties | 5 ++--- build.xml | 8 ++++---- docker/Dockerfile.armv7 | 19 ++++++------------- package_macos_app.sh | 14 +++++++++++++- snap/snapcraft.yaml | 4 ++-- source/net/yacy/peers/operation/yacySeedUploadScp.xml | 3 +-- startYACY.bat | 17 +++++++++++++++++ startYACY.sh | 15 +++++++++++++++ 12 files changed, 75 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ant-build-pull-request.yaml b/.github/workflows/ant-build-pull-request.yaml index 4c4441449..52a050c8a 100644 --- a/.github/workflows/ant-build-pull-request.yaml +++ b/.github/workflows/ant-build-pull-request.yaml @@ -8,10 +8,10 @@ jobs: if: github.repository == 'yacy/yacy_search_server' steps: - uses: actions/checkout@master - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - name: Build with ant run: ant clean all dist diff --git a/.github/workflows/ant-build.yaml b/.github/workflows/ant-build.yaml index d76843506..10488dc4f 100644 --- a/.github/workflows/ant-build.yaml +++ b/.github/workflows/ant-build.yaml @@ -18,10 +18,10 @@ jobs: with: fetch-depth: 0 # Required for git version info in build - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'temurin' - name: Install build dependencies diff --git a/README.md b/README.md index b0538b7f3..6ac533d1b 100644 --- a/README.md +++ b/README.md @@ -55,11 +55,11 @@ To get a ready-to-run production package, run YaCy from Docker. ### Compile and run YaCy from git sources -You need Java 11 or later to run YaCy and ant to build YaCy. +You need Java 17 or later to run YaCy and ant to build YaCy. This would install the requirements on debian: ``` -sudo apt-get install openjdk-11-jdk-headless ant +sudo apt-get install openjdk-17-jdk-headless ant ``` Then clone the repository and build the application: diff --git a/build.nsi b/build.nsi index 379d60196..0cce0f5ce 100644 --- a/build.nsi +++ b/build.nsi @@ -67,9 +67,9 @@ SetCompressor /SOLID LZMA !insertmacro MUI_LANGUAGE "English" -LangString javaMissing 0 "Java 11 or newer is required to run YaCy. Download and install the latest Temurin JRE now?" -LangString javaDownloadFail 0 "Java download failed. Please install Java 11+ manually." -LangString javaInstallFail 0 "Java 11+ was not found after installation. YaCy may not start until Java is installed." +LangString javaMissing 0 "Java 17 or newer is required to run YaCy. Download and install the latest Temurin JRE now?" +LangString javaDownloadFail 0 "Java download failed. Please install Java 17+ manually." +LangString javaInstallFail 0 "Java 17+ was not found after installation. YaCy may not start until Java is installed." LangString keepData 0 "Remove YaCy user data as well?" Var JavaVersion @@ -150,7 +150,9 @@ Function EnsureJava Call GetJavaVersion Push "Java detection: found=$JavaFound version='$JavaVersion' major=$JavaMajor" Call LogLine - StrCmp $JavaFound "1" JavaOk JavaMissing + StrCmp $JavaFound "1" JavaVersionCheck JavaMissing + JavaVersionCheck: + IntCmp $JavaMajor 17 JavaOk JavaMissing JavaOk JavaMissing: Push "Java detection: no Java found" Call LogLine @@ -171,6 +173,7 @@ Function EnsureJava Push "Java detection (post-install): found=$JavaFound version='$JavaVersion' major=$JavaMajor" Call LogLine StrCmp $JavaFound "1" 0 JavaStillLow + IntCmp $JavaMajor 17 JavaContinue JavaStillLow JavaContinue JavaStillLow: MessageBox MB_ICONEXCLAMATION "$(javaInstallFail)" JavaContinue: @@ -203,8 +206,8 @@ Function GetJavaVersion Call FindJavaFromPath ${If} $JavaFound == "1" ${If} $JavaMajor == "0" - StrCpy $JavaMajor "11" - Push "Java detection: version unknown, assuming >=11" + StrCpy $JavaMajor "17" + Push "Java detection: version unknown, assuming >=17" Call LogLine ${EndIf} ${EndIf} diff --git a/build.properties b/build.properties index b2c0281d2..17a6c1a37 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,5 @@ -# defining some compiler arguments -javacSource=11 -javacTarget=11 +# Java release used for source compatibility, API compatibility and bytecode +javacRelease=17 # Release Configuration releaseVersion=1.941 diff --git a/build.xml b/build.xml index 2aad2974a..b4f28e0f7 100644 --- a/build.xml +++ b/build.xml @@ -179,8 +179,8 @@ + release="${javacRelease}" encoding="UTF-8" + nowarn="on"> @@ -336,8 +336,8 @@ + debug="true" debuglevel="lines,vars,source" includeantruntime="false" + release="${javacRelease}" encoding="UTF-8"> diff --git a/docker/Dockerfile.armv7 b/docker/Dockerfile.armv7 index 284cc83ab..1de87b13e 100644 --- a/docker/Dockerfile.armv7 +++ b/docker/Dockerfile.armv7 @@ -7,28 +7,21 @@ # docker run -d --name yacy -p 8090:8090 -p 8443:8443 -v yacy_data:/opt/yacy_search_server/DATA --log-opt max-size=200m --log-opt max-file=2 yacy/yacy_search_server:armv7 -# Base image : latest Debian stable official jdk 11 image from Docker -FROM arm32v7/openjdk:11-jdk as builder +# Java 17 is installed from Debian's ARMv7 packages. +FROM arm32v7/debian:bookworm-slim # Install needed packages not in base image -RUN apt-get update && apt-get install -yq curl && \ +RUN apt-get update && apt-get install -yq ant curl openjdk-17-jdk-headless && \ rm -rf /var/lib/apt/lists/* # set current working dir & copy sources WORKDIR /opt COPY . /opt/yacy_search_server/ -# .git dir deleted here because .git is needed during the build to deterime the version, +# .git dir is deleted after the build because it is needed to determine the version, # but isn't required at runtime -RUN ant compile -f /opt/yacy_search_server/build.xml \ -RUN rm -rf /opt/yacy_search_server/.git && \ - apt-get update && \ - apt-get install -yq ant && \ - ant compile -f /opt/yacy_search_server/build.xml && \ - apt-get purge -yq --auto-remove ant && \ - apt-get clean && \ - rm -fr /opt/yacy_search_server/.git && \ - rm -rf /var/lib/apt/lists/* +RUN ant compile -f /opt/yacy_search_server/build.xml && \ + rm -rf /opt/yacy_search_server/.git # Set initial admin password: "yacy" (encoded with custom yacy md5 function net.yacy.cora.order.Digest.encodeMD5Hex()) RUN sed -i "/adminAccountBase64MD5=/c\adminAccountBase64MD5=MD5:8cffbc0d66567a0987a4aba1ec46d63c" /opt/yacy_search_server/defaults/yacy.init && \ diff --git a/package_macos_app.sh b/package_macos_app.sh index f0b58d34e..76964760d 100755 --- a/package_macos_app.sh +++ b/package_macos_app.sh @@ -311,7 +311,19 @@ elif command -v /usr/libexec/java_home >/dev/null 2>&1; then fi if [[ -z "${JAVA_BIN}" ]]; then - echo "Unable to find a Java runtime. Please install Java (JDK 11+) and try again." >&2 + echo "Unable to find a Java runtime. Please install Java (JDK 17+) and try again." >&2 + exit 1 +fi + +JAVA_SPEC_VERSION="$("${JAVA_BIN}" -XshowSettings:properties -version 2>&1 | sed -n 's/^[[:space:]]*java.specification.version = //p' | head -n 1)" +JAVA_MAJOR_VERSION="${JAVA_SPEC_VERSION#1.}" +JAVA_MAJOR_VERSION="${JAVA_MAJOR_VERSION%%.*}" +if [[ ! "${JAVA_MAJOR_VERSION}" =~ ^[0-9]+$ ]]; then + echo "Unable to determine the Java version reported by ${JAVA_BIN}." >&2 + exit 1 +fi +if (( JAVA_MAJOR_VERSION < 17 )); then + echo "Java 17 or newer is required to run YaCy (found Java ${JAVA_SPEC_VERSION})." >&2 exit 1 fi diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 6acc25e27..db69982c4 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -45,7 +45,7 @@ parts: - dist source: https://github.com/yacy/yacy_search_server.git build-packages: - - openjdk-8-jdk + - openjdk-17-jdk override-build: | snapcraftctl build - tar -xzf RELEASE/yacy*.tar.gz -C "$SNAPCRAFT_PART_INSTALL/" \ No newline at end of file + tar -xzf RELEASE/yacy*.tar.gz -C "$SNAPCRAFT_PART_INSTALL/" diff --git a/source/net/yacy/peers/operation/yacySeedUploadScp.xml b/source/net/yacy/peers/operation/yacySeedUploadScp.xml index 97be4109b..c8be787e5 100644 --- a/source/net/yacy/peers/operation/yacySeedUploadScp.xml +++ b/source/net/yacy/peers/operation/yacySeedUploadScp.xml @@ -11,7 +11,7 @@ - + @@ -70,4 +70,3 @@ - diff --git a/startYACY.bat b/startYACY.bat index 93602ea7b..3701a9f3a 100644 --- a/startYACY.bat +++ b/startYACY.bat @@ -1,6 +1,23 @@ @Echo Off title YaCy +where java >nul 2>&1 +if errorlevel 1 ( + Echo Java was not found. Java 17 or newer is required to run YaCy. + GoTo :END +) +set "JAVA_SPEC_VERSION=" +for /F "tokens=3" %%v in ('java -XshowSettings:properties -version 2^>^&1 ^| findstr /C:"java.specification.version ="') do set "JAVA_SPEC_VERSION=%%v" +if not defined JAVA_SPEC_VERSION ( + Echo Unable to determine the installed Java version. Java 17 or newer is required. + GoTo :END +) +for /F "tokens=1 delims=." %%v in ("%JAVA_SPEC_VERSION%") do set "JAVA_MAJOR_VERSION=%%v" +if %JAVA_MAJOR_VERSION% LSS 17 ( + Echo Java 17 or newer is required to run YaCy. Found Java %JAVA_SPEC_VERSION%. + GoTo :END +) + REM setting startup type for proper restart if "%YACY_DATA%"=="" set "YACY_DATA=%LOCALAPPDATA%\YaCy" set "YACY_DATA_DIR=%YACY_DATA%\DATA" diff --git a/startYACY.sh b/startYACY.sh index 3b19fcefb..ef6abbc29 100755 --- a/startYACY.sh +++ b/startYACY.sh @@ -38,6 +38,21 @@ then exit 1 fi +JAVA_SPECIFICATION_VERSION="`"$JAVA" -XshowSettings:properties -version 2>&1 | sed -n 's/^[[:space:]]*java.specification.version = //p' | head -n 1`" +JAVA_MAJOR_VERSION="${JAVA_SPECIFICATION_VERSION#1.}" +JAVA_MAJOR_VERSION="${JAVA_MAJOR_VERSION%%.*}" +case "$JAVA_MAJOR_VERSION" in + ''|*[!0-9]*) + echo "Unable to determine the Java version reported by $JAVA." + exit 1 + ;; +esac +if [ "$JAVA_MAJOR_VERSION" -lt 17 ] +then + echo "Java 17 or newer is required to run YaCy (found Java $JAVA_SPECIFICATION_VERSION)." + exit 1 +fi + usage() { cat - <