3

I have already read and tried a lot posts on SO, but no one has solved this issue.

I set to enviroment variables for JDK and JRE release. I have add the same values within both sections "user's variables for USER" and "system variables". The variables that I have added is: JAVA_HOME->C:\PROGRA~1\Java\JDK9U4~1 and JRE_HOME->C:\PROGRA~1\Java\JRE9U4~1.

My installations directory for JDK and JRE are respectly "C:\Program Files\Java\JDK 9u4" and "C:\Program Files\Java\JRE 9u4".

When I run catalina_start.bat, I getting this error:

[XAMPP]: Searching JDK HOME with reg query ...
Errore: The registry key or the specified value could not be found.
. [XAMPP]: Cannot find current JDK installation!
. [XAMPP]: Cannot set JAVA_HOME. Aborting ...
done.

The text of my catalina_start.bat file (and I think this is default) is:

@echo off
::::::::::::::::::::::::::::::::::::
::  Set JAVA_HOME and   ::
::::::::::::::::::::::::::::::::::::

IF EXIST tomcat\logs\catalina.pid (
  del /F/Q tomcat\logs\catalina.pid
) 

echo.
echo [XAMPP]: Searching JDK HOME with reg query ...
set KeyName=HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit

reg query "%KeyName%" /s
if %ERRORLEVEL% == 1 (
  echo . [XAMPP]: Cannot find current JDK installation! 
  echo . [XAMPP]: Cannot set JAVA_HOME. Aborting ...
  goto :END
)

set "CURRENT_DIR=%cd%"
set "CATALINA_HOME=%CURRENT_DIR%"

:: only for windows 32 bit if you have problems with the tcnative-1.dll
:: set CATALINA_OPTS=-Djava.library.path="%CATALINA_HOME%\bin"

set Cmd=reg query "%KeyName%" /s
for /f "tokens=2*" %%i in ('%Cmd% ^| find "JavaHome"') do set JAVA_HOME=%%j

echo.
echo [XAMPP]: Seems fine!
echo [XAMPP]: Set JAVA_HOME : %JAVA_HOME%
echo [XAMPP]: Set CATALINA_HOME : %CATALINA_HOME%
echo.

if %ERRORLEVEL% == 0 (
echo run > logs\catalina.pid
)

"%CATALINA_HOME%\bin\catalina.bat" run


:END
echo done.
pause

I have already tried many solutions, but nothing have helped me. I wondered if someone could to help me with this, I would be very grateful. I hope that I have explained myself clearly (sorry for my english). Thanks for advices.

Huntwer
  • 121
  • 2
  • 8

3 Answers3

3

I solved the issue by changing the line

set KeyName=HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit

to

set KeyName=HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\JDK

I had a look into my registry and found the expected Key had been created with the commonly used abbreviation JDK.

As an extra i also changed my tomcat_service_install.bat to the above mentioned keyname. This made the installation as a windows service possible.

DKSan
  • 4,187
  • 3
  • 25
  • 35
  • Thx, I just want to point out that this configuration must be in C:\xampp\tomcat\catalina_start.bat -Just open the catalina_start.bat in any text editor and apply the changes – Husam Ebish Mar 24 '22 at 20:21
2

I solved the problem for me by downloading Java 11.0.2 using the zip-file. Thus it didn't create the registry entry, so I manually added it. The code above only searches for the registry key in KeyName, so just create the key as

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\<your version>

There is no need to add any values, just create the path.

You can do this by

  • pressing Win+R
  • typing "regedit"
  • then go to HKEY_LOCAL_MACHINE -> SOFTWARE
  • right click on SOFTWARE
  • select New -> Key
  • name the new folder "JavaSoft"
  • right click on the newly created JavaSoft folder
  • select New -> Key
  • name the new folder "Java Development Kit".

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
Abhishek
  • 21
  • 2
0

add a row your catalina_start.bat as below line ;

set "CURRENT_DIR=%cd%"
set "CATALINA_HOME=%CURRENT_DIR%"
set JAVA_HOME=C:\yourJDKpath