Skip to content
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
7 changes: 7 additions & 0 deletions apache-maven/src/assembly/maven/bin/mvn
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ else
fi
fi

if ! "$JAVACMD" --enable-native-access=ALL-UNNAMED -version >/dev/null 2>&1; then
echo "Error: Apache Maven 4.x requires Java 17 or newer to run." >&2
"$JAVACMD" -version >&2
echo "Please upgrade your Java installation or set JAVA_HOME to point to a compatible JDK." >&2
exit 1
fi

# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
Expand Down
10 changes: 10 additions & 0 deletions apache-maven/src/assembly/maven/bin/mvn.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ if not exist "%JAVACMD%" (
echo The java.exe command does not exist in PATH nor is JAVA_HOME set, so Apache Maven cannot be started. >&2
goto error
)

@REM Check Java version by testing the Java 17+ flag
"%JAVACMD%" --enable-native-access=ALL-UNNAMED -version >nul 2>&1
if ERRORLEVEL 1 (
echo Error: Apache Maven 4.x requires Java 17 or newer to run. >&2
"%JAVACMD%" -version >&2
echo Please upgrade your Java installation or set JAVA_HOME to point to a compatible JDK. >&2
goto error
)

:chkMHome
set "MAVEN_HOME=%~dp0"
set "MAVEN_HOME=%MAVEN_HOME:~0,-5%"
Expand Down