Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-4226

Better detection of JAVA_HOME on Apple Mac OS X

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.2.2
    • Command Line
    • None

    Description

      On mac JAVA_HOME is detected by using the following code:

                 if [ -z "$JAVA_VERSION" ] ; then
                   JAVA_VERSION="CurrentJDK"
                 else
                   echo "Using Java version: $JAVA_VERSION"
                 fi
                 if [ -z "$JAVA_HOME" ] ; then
                   JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
                 fi
      

      But this does not work in collaboration with Using "Java preferences" to change the actual java version to use as "CurrentJDK" does not change once you update the "java applications" order.

      There is an alternative (at least on Leopard) for determining current java home that is based on Java Preferences by using an apple provided script. So, as a replacement fo rthe code above the following could be used.

                 if [ -z "$JAVA_HOME" ] ; then
                   JAVA_HOME=`/usr/libexec/java_home | tail -1`
                 fi
      

      Could also be taht this is teh first attempt and if fails use the current way of determining home.

      Attachments

        Issue Links

          Activity

            People

              jvanzyl Jason van Zyl
              adreghiciu Alin George Dreghiciu
              Votes:
              12 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: