This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 0ccae46c22013e7b5ba7377334ac2315f88b12b7
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 11 10:51:48 2023 +0100

    Align JRE_HOME/JAVA_HOME handling with setclasspath.bat
---
 bin/service.bat | 43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/bin/service.bat b/bin/service.bat
index fae79207b2..be6eca7e03 100755
--- a/bin/service.bat
+++ b/bin/service.bat
@@ -103,30 +103,42 @@ exit /b 1
 cd "%CURRENT_DIR%"
 
 rem Make sure prerequisite environment variables are set
-if not "%JAVA_HOME%" == "" goto gotJdkHome
 if not "%JRE_HOME%" == "" goto gotJreHome
+if not "%JAVA_HOME%" == "" goto gotJavaHome
 echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
 echo Service will try to guess them from the registry.
-goto okJavaHome
-:gotJreHome
-if not exist "%JRE_HOME%\bin\java.exe" goto noJavaHome
-goto okJavaHome
-:gotJdkHome
-if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome
-if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
-if not "%JRE_HOME%" == "" goto okJavaHome
+goto okJava
+
+:gotJavaHome
+rem No JRE given, check if JAVA_HOME is usable as JRE_HOME
+if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHomeAsJre
+rem Use JAVA_HOME as JRE_HOME
 set "JRE_HOME=%JAVA_HOME%"
-goto okJavaHome
-:noJavaHome
-echo The JAVA_HOME environment variable is not defined correctly
+goto okJava
+
+:noJavaHomeAsJre
+echo The JAVA_HOME environment variable is not defined correctly.
+echo JAVA_HOME=%JAVA_HOME%
+echo NB: JAVA_HOME should point to a JDK not a JRE.
+exit /b 1
+
+:gotJreHome
+rem Check if we have a usable JRE
+if not exist "%JRE_HOME%\bin\java.exe" goto noJreHome
+goto okJava
+
+:noJreHome
+rem Needed at least a JRE
+echo The JRE_HOME environment variable is not defined correctly
+echo JRE_HOME=%JRE_HOME%
 echo This environment variable is needed to run this program
-echo NB: JAVA_HOME should point to a JDK not a JRE
 exit /b 1
-:okJavaHome
+
+:okJava
 if not "%CATALINA_BASE%" == "" goto gotBase
 set "CATALINA_BASE=%CATALINA_HOME%"
-:gotBase
 
+:gotBase
 rem Process the requested command
 if /i %SERVICE_CMD% == install goto doInstall
 if /i %SERVICE_CMD% == remove goto doRemove
@@ -160,7 +172,6 @@ rem Install the service
 echo Installing the service '%SERVICE_NAME%' ...
 echo Using CATALINA_HOME:    "%CATALINA_HOME%"
 echo Using CATALINA_BASE:    "%CATALINA_BASE%"
-echo Using JAVA_HOME:        "%JAVA_HOME%"
 echo Using JRE_HOME:         "%JRE_HOME%"
 
 rem Try to use the server jvm


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to