Solr
  1. Solr
  2. SOLR-6694

Auto detect JAVA_HOME in bin\start.cmd

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.10.2
    • Fix Version/s: 4.10.3, 5.0
    • Component/s: scripts and tools
    • Labels:
      None
    • Environment:

      Windows

      Description

      The start script requires JAVA_HOME to be set.

      The Java installer on Windows does not set JAVA_HOME, so it is an obstacle for new users who wants to test. What the installer does is to set some registry values, and we can detect those to find a JAVA_HOME to use. It will give a better user experience.

        Activity

        Hide
        Jan Høydahl added a comment -

        Here's some code from a start script I created long ago:

        echo "Detecting JAVA_HOME"
        if "%JAVA_HOME%"=="" call:FIND_JAVA_HOME
        echo "Java home: %JAVA_HOME%"
        goto:DETECTED
        
        :FIND_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
        goto:EOF
        
        :DETECTED
        echo "Do whatever"
        
        Show
        Jan Høydahl added a comment - Here's some code from a start script I created long ago: echo "Detecting JAVA_HOME" if "%JAVA_HOME%"=="" call:FIND_JAVA_HOME echo "Java home: %JAVA_HOME%" goto:DETECTED :FIND_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 goto:EOF :DETECTED echo "Do whatever"
        Hide
        ASF subversion and git services added a comment -

        Commit 1642767 from Timothy Potter in branch 'dev/trunk'
        [ https://svn.apache.org/r1642767 ]

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

        Show
        ASF subversion and git services added a comment - Commit 1642767 from Timothy Potter in branch 'dev/trunk' [ https://svn.apache.org/r1642767 ] SOLR-6694 : auto-detect JAVA_HOME using the Windows registry
        Hide
        ASF subversion and git services added a comment -

        Commit 1642768 from Timothy Potter in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1642768 ]

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

        Show
        ASF subversion and git services added a comment - Commit 1642768 from Timothy Potter in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1642768 ] SOLR-6694 : auto-detect JAVA_HOME using the Windows registry
        Hide
        ASF subversion and git services added a comment -

        Commit 1642777 from Timothy Potter in branch 'dev/branches/lucene_solr_4_10'
        [ https://svn.apache.org/r1642777 ]

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

        Show
        ASF subversion and git services added a comment - Commit 1642777 from Timothy Potter in branch 'dev/branches/lucene_solr_4_10' [ https://svn.apache.org/r1642777 ] SOLR-6694 : auto-detect JAVA_HOME using the Windows registry
        Hide
        ASF subversion and git services added a comment -

        Commit 1642780 from Timothy Potter in branch 'dev/trunk'
        [ https://svn.apache.org/r1642780 ]

        SOLR-6694: fix misplaced percent found when fixing this issue

        Show
        ASF subversion and git services added a comment - Commit 1642780 from Timothy Potter in branch 'dev/trunk' [ https://svn.apache.org/r1642780 ] SOLR-6694 : fix misplaced percent found when fixing this issue
        Hide
        ASF subversion and git services added a comment -

        Commit 1642781 from Timothy Potter in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1642781 ]

        SOLR-6694: fix misplaced percent found when fixing this issue

        Show
        ASF subversion and git services added a comment - Commit 1642781 from Timothy Potter in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1642781 ] SOLR-6694 : fix misplaced percent found when fixing this issue
        Hide
        Anshum Gupta added a comment -

        Bulk close after 5.0 release.

        Show
        Anshum Gupta added a comment - Bulk close after 5.0 release.

          People

          • Assignee:
            Timothy Potter
            Reporter:
            Jan Høydahl
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development