diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 8c233fb0c7c..1d6e2bb2715 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -510,6 +510,9 @@ Other Changes relative paths for solrconfig.xml references with solr.install.dir system property; bin/solr scripts will set it appropriately. (ehatcher) +* SOLR-6694: Auto-detect JAVA_HOME using the Windows registry if it is not set + (janhoy, Timothy Potter) + ================== 4.10.2 ================== Bug FixesAnalyticsComponent diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd index e4bd24e016c..863b0154f6d 100644 --- a/solr/bin/solr.cmd +++ b/solr/bin/solr.cmd @@ -38,6 +38,15 @@ IF EXIST "%SOLR_INCLUDE%" CALL "%SOLR_INCLUDE%" REM Verify Java is available IF DEFINED SOLR_JAVA_HOME set "JAVA_HOME=%SOLR_JAVA_HOME%" +REM Try to detect JAVA_HOME from the registry +IF NOT DEFINED JAVA_HOME ( + FOR /F "skip=2 tokens=2*" %%A IN ('REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment" /v CurrentVersion') DO set CurVer=%%B + FOR /F "skip=2 tokens=2*" %%A IN ('REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment\!CurVer!" /v JavaHome') DO ( + set JAVA_HOME=%%B + @echo Detected JAVA_HOME=%%B + ) +) + IF NOT DEFINED JAVA_HOME goto need_java_home set JAVA_HOME=%JAVA_HOME:"=% "%JAVA_HOME%"\bin\java -version:1.8 -version > nul 2>&1