Maven 2 & 3

JAVACMD set incorrectly when JAVA_HOME is not set

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0.8
  • Fix Version/s: 2.0.9
  • Component/s: Command Line
  • Labels:
    None
  • Patch Submitted:
    Yes
  • Number of attachments :
    1

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`"

Activity

Hide
Vincent Siveton added a comment -

Patch applied. Thanks!

Show
Vincent Siveton added a comment - Patch applied. Thanks!

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: