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

JAVACMD set incorrectly when JAVA_HOME is not set

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.8
    • 2.0.9
    • Command Line
    • None
    • Patch

    Description

      In the mvn shell script, when the JAVA_HOME environment variable is not set, the script sets JAVACMD to java, probably as a best effort, hoping it is on the user's PATH. 4 lines beneath that, the JAVACMD is tested for executability, but since it is not a path to the java executable, but just the java command, this fails.

      The relevant part of the script (lines 122-139):

      if [ -z "$JAVACMD" ] ; then
      if [ -n "$JAVA_HOME" ] ; then
      if [ -x "$JAVA_HOME/jre/sh/java" ] ; then

      1. IBM's JDK on AIX uses strange locations for the executables
        JAVACMD="$JAVA_HOME/jre/sh/java"
        else
        JAVACMD="$JAVA_HOME/bin/java"
        fi
        else
        JAVACMD=java
        fi
        fi

      if [ ! -x "$JAVACMD" ] ; then
      echo "Error: JAVA_HOME is not defined correctly."
      echo " We cannot execute $JAVACMD"
      exit 1
      fi

      Line 131 should be changed to:
      JAVACMD="`which java`"

      Attachments

        1. mvn.patch
          0.2 kB
          Matthijs Wensveen

        Activity

          People

            siveton Siveton Vincent
            wensveen Matthijs Wensveen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: