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

mvn cannot execute /usr/libexec/java_home/bin/java on OS X.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.3
    • 3.3.1
    • Command Line
    • None
    • Mac OS X 10.9.4

    Description

      From 3.2.3, mvn cannot start and outputs the following error.

      $ ./apache-maven-3.2.3/bin/mvn -version
      Error: JAVA_HOME is not defined correctly.
        We cannot execute /usr/libexec/java_home/bin/java
      

      3.2.2 doesn't have this problem.

      $ ./apache-maven-3.2.2/bin/mvn -version
      Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T22:51:42+09:00)
      Maven home: /Users/xxx/tmp/apache-maven-3.2.2
      Java version: 1.8.0_11, vendor: Oracle Corporation
      Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre
      Default locale: en_US, platform encoding: UTF-8
      OS name: "mac os x", version: "10.9.4", arch: "x86_64", family: "mac"
      

      When I modified bin/mvn like the following, this problem was gone.

      --- bin/mvn.orig	2014-09-10 03:33:52.000000000 +0900
      +++ bin/mvn	2014-09-10 03:34:18.000000000 +0900
      @@ -83,7 +83,7 @@
                    #
                    # Apple JDKs
                    #
      -             export JAVA_HOME=/usr/libexec/java_home
      +             export JAVA_HOME="`/usr/libexec/java_home`"
                  fi
                  ;;
       esac
      

      Maybe MNG-5658 is related to this problem. /usr/libexec/java_home is a command(java_home(1)), and $(command) is a style of Command Substitution (Another(old) style is `command`).
      So removing "$()" breaks the JAVA_HOME detection on OS X.

      Attachments

        Issue Links

          Activity

            People

              mfriedenhagen Mirko Friedenhagen
              asdftf Takayoshi Fujiki
              Votes:
              3 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: