You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Rob Elliot (JIRA)" <ji...@codehaus.org> on 2012/08/08 23:54:21 UTC

[jira] (MNG-4226) Better detection of JAVA_HOME on Apple Mac OS X

    [ https://jira.codehaus.org/browse/MNG-4226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=305856#comment-305856 ] 

Rob Elliot commented on MNG-4226:
---------------------------------

I just wasted an evening trying to establish why setting the preferred Java version to Java 7 in Mac's Java Preferences still left Maven using Java 6, due to this issue.  Ant does it the right way, via /usr/libexec/java_home.  Attached is a patch.
                
> Better detection of JAVA_HOME on Apple Mac OS X
> -----------------------------------------------
>
>                 Key: MNG-4226
>                 URL: https://jira.codehaus.org/browse/MNG-4226
>             Project: Maven 2 & 3
>          Issue Type: Improvement
>          Components: Command Line
>            Reporter: Alin Dreghiciu
>             Fix For: Issues to be reviewed for 3.x
>
>         Attachments: MNG-4226-apache-maven.patch
>
>
> On mac JAVA_HOME is detected by using the following code:
> {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
> {code}
> 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.
> {code}
>            if [ -z "$JAVA_HOME" ] ; then
>              JAVA_HOME=`/usr/libexec/java_home | tail -1`
>            fi
> {code}
> Could also be taht this is teh first attempt and if fails use the current way of determining home.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira