Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-1799

JAVA_HOME autodiscovery not working on Windows 7 (karaf.bat)

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.9
    • Fix Version/s: None
    • Component/s: karaf-os-integration
    • Labels:
      None
    • Environment:

      Windows 7 Professional, JDK 1.6.0_35, JDK 1.7.0_07, jre6, jre7

      Description

      When running karaf.bat without setting JAVA_HOME, karaf.bat tries to determine JAVA_HOME automatically.
      The following happens on Windows 7:
      1. The built in windows security manager asks for permission to allow regedit to access the registry twice.
      2. karaf.bat exits with message "Unable to retrieve JAVA_HOME"

        Activity

        Hide
        rwm Raphael Majeed added a comment -

        Better solution for JAVA_HOME autodiscovery: use "REG QUERY ..." (available since WinXP)
        e.g. try running

        REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment" /v CurrentVersion
        REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment\1.6" /v JavaHome
        

        in the console.

        See also http://www.chriskopec.com/blog/2009/jun/15/automatic-discovery-java_home-batch-file/

        Show
        rwm Raphael Majeed added a comment - Better solution for JAVA_HOME autodiscovery: use "REG QUERY ..." (available since WinXP) e.g. try running REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment" /v CurrentVersion REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment\1.6" /v JavaHome in the console. See also http://www.chriskopec.com/blog/2009/jun/15/automatic-discovery-java_home-batch-file/
        Hide
        pieber Andreas Pieber added a comment -

        Hey Raphael,

        Thank you very much for the update. Would you mind packing the proposed changes into a patch and attach it to the jira making it easier for us to review and apply your change?

        Thank you very much and kind regards,
        Andreas

        Show
        pieber Andreas Pieber added a comment - Hey Raphael, Thank you very much for the update. Would you mind packing the proposed changes into a patch and attach it to the jira making it easier for us to review and apply your change? Thank you very much and kind regards, Andreas
        Hide
        gnt Guillaume Nodet added a comment -

        I would suggest to enhance the batch to also search for "HKLM\Software\JavaSoft\Java Development Kit" in case "Java Runtime Environment" keys do not exist.
        I just installed a JDK on a bare windows and had the above configuration.

        Show
        gnt Guillaume Nodet added a comment - I would suggest to enhance the batch to also search for "HKLM\Software\JavaSoft\Java Development Kit" in case "Java Runtime Environment" keys do not exist. I just installed a JDK on a bare windows and had the above configuration.
        Hide
        charly Heath Kesler added a comment -

        added logic that will check both the JRE and JDK registry entries for the JAVA_HOME if it is not already set. I tested this on windows 7 and it works. I would like some one else to review it since I do not have a lot of windows scripting experience.

        Show
        charly Heath Kesler added a comment - added logic that will check both the JRE and JDK registry entries for the JAVA_HOME if it is not already set. I tested this on windows 7 and it works. I would like some one else to review it since I do not have a lot of windows scripting experience.
        Hide
        jgoodyear Jamie goodyear added a comment -

        The logic appears good to me.

        Given no differences between win7, xp, and win8 in regards to the registry entry names, I'd say it looks good to go.

        Show
        jgoodyear Jamie goodyear added a comment - The logic appears good to me. Given no differences between win7, xp, and win8 in regards to the registry entry names, I'd say it looks good to go.
        Hide
        charly Heath Kesler added a comment -

        I did leave the current logic in place for now to keep it backwards compatible. I just made it error thru and try this new logic before failing out.

        Show
        charly Heath Kesler added a comment - I did leave the current logic in place for now to keep it backwards compatible. I just made it error thru and try this new logic before failing out.

          People

          • Assignee:
            Unassigned
            Reporter:
            rwm Raphael Majeed
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:

              Development