mirror of https://github.com/apache/maven.git
[MNG-8376] Exit with a nicer error message when running on JDK < 17 (#1916)
This commit is contained in:
parent
ce096fea3e
commit
bad1387892
|
@ -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() {
|
||||
|
|
|
@ -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%"
|
||||
|
|
Loading…
Reference in New Issue