SOLR-6694: auto-detect JAVA_HOME using the Windows registry

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1642767 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy Potter 2014-12-01 22:00:23 +00:00
parent e989394fb2
commit 224f6f59c1
2 changed files with 12 additions and 0 deletions

View File

@ -510,6 +510,9 @@ Other Changes
relative paths for solrconfig.xml <lib> 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

View File

@ -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