You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Alin Dreghiciu (JIRA)" <ji...@codehaus.org> on 2009/07/01 23:23:05 UTC

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

Better detection of JAVA_HOME on Apple Mac OS X
-----------------------------------------------

                 Key: MNG-4226
                 URL: http://jira.codehaus.org/browse/MNG-4226
             Project: Maven 2
          Issue Type: Improvement
          Components: Command Line
            Reporter: Alin Dreghiciu


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 contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Posted by "Nikolaj Schumacher (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/MNG-4226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=319774#comment-319774 ] 

Nikolaj Schumacher commented on MNG-4226:
-----------------------------------------

This should probably be revisited soon. Apple recently removed the "Java Preferences" and has everything in the system default to Java 7, if that is installed. The pre-installed version of mvn 3.0.3 also uses Java 7, but any upgrade to 3.0.4 will revert back to Java 6 due to this issue.

I assume this will surprise quite a few people and cost them time tracking it down. And the current hard-coded /System/Library path will probably break as soon as Apple drops their own JRE (which they deprecated in 2010.)
                
> 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

        

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

Posted by "Rob Elliot (JIRA)" <ji...@codehaus.org>.
    [ 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

        

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

Posted by "Daniel Serodio (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/MNG-4226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=304151#comment-304151 ] 

Daniel Serodio commented on MNG-4226:
-------------------------------------

Yes, please apply this fix.
{{JAVA_HOME=`/usr/libexec/java_home`}} is the proper way to set JAVA_HOME on OS X. From {{man java_home}}, I don't think the {{| tail -1}} is needed.
                
> 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
>
>
> 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

        

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

Posted by "Tamás Cservenák (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/MNG-4226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=315031#comment-315031 ] 

Tamás Cservenák edited comment on MNG-4226 at 12/5/12 2:28 AM:
---------------------------------------------------------------

You can circumvent current maven deployments (3.0.4 inclusive) without modifying them, by adding following file in {{/etc/mavenrc}}:

{noformat}
JAVA_HOME=`/usr/libexec/java_home -v 1.7`
{noformat}

Note: this will make Maven use same Java system wide!
                
      was (Author: cstamas):
    You can circumvent current maven deployments (3.0.4 inclusive) without modifying them, by adding following file in {{/etc/mavenrc}}:

{noformat}
#!/bin/bash

JAVA_HOME=`/usr/libexec/java_home -v 1.7`
{noformat}

Note: this will make Maven use same Java system wide!
                  
> 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

       

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

Posted by "Rob Elliot (JIRA)" <ji...@codehaus.org>.
     [ https://jira.codehaus.org/browse/MNG-4226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rob Elliot updated MNG-4226:
----------------------------

    Attachment: MNG-4226-apache-maven.patch

Patch to fix java version detection on OS/X so that it uses the standard Java Preferences mechanism rather than always using Java 6.
                
> 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

        

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

Posted by "Tamás Cservenák (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/MNG-4226?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=315031#comment-315031 ] 

Tamás Cservenák commented on MNG-4226:
--------------------------------------

You can circumvent current maven deployments (3.0.4 inclusive) without modifying them, by adding following file in {{/etc/mavenrc}}:

{noformat}
#!/bin/bash

JAVA_HOME=`/usr/libexec/java_home -v 1.7`
{noformat}

Note: this will make Maven use same Java system wide!
                
> 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