You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Weiqi Gao <we...@gmail.com> on 2006/08/07 13:55:37 UTC

The mvn script errors out when JAVA_HOME is not defined

Hi,

I'm learning Maven 2.0.4 and encountered an error when invoking the
mvn script.  The following piece of script seems to be the cause of my
error message:

========================================
if [ -z "$JAVACMD" ] ; then
  if [ -n "$JAVA_HOME"  ] ; then
    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
      # 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
========================================

I don't have my JAVA_HOME set, so my JAVACMD has the value of "java"
when the [ -x "$JAVACMD" ] check is done.  Naturally it failed because
the file "java" doesn't exist in the current directory.

It would make more sense to do the [ -x "$JAVACMD" ] check in the [ -n
"JAVA_HOME" ] branch of the if statement in the previous block (when
$JAVACMD is built up).

Thanks,
-- 
Weiqi Gao (高为奇)
weiqigao@gmail.com
http://www.weiqigao.com/blog/

Re: The mvn script errors out when JAVA_HOME is not defined

Posted by ben short <be...@benshort.co.uk>.
Thats not the "standard" location for linux or osx.

On 8/7/06, Weiqi Gao <we...@gmail.com> wrote:
> On 8/7/06, Vincent Siveton <vi...@gmail.com> wrote:
> > JAVA_HOME is a requirement
> > http://maven.apache.org/download.html#installation
>
> That piece of documentation seems to be wrong.  By reading the script,
> I certainly get the impression that the script is furiously trying to
> figure out where my JAVA_HOME is when the JAVA_HOME environment is not
> set.
>
> Right after the block of script I cited, there is another check for
> JAVA_HOME and it gives a warning if JAVA_HOME is not set.
>
> If Maven is going to require the setting of JAVA_HOME anyway, all that
> extra script are pointless.
>
> Of course I'm advocating that Maven not requiring me to set JAVA_HOME
> if I have installed my JDK in the "standard" location (such as
> C:\Program Files\Java\jdk1.5.0_12.).
>
> --
> Weiqi Gao (高为奇)
> weiqigao@gmail.com
> http://www.weiqigao.com/blog/
>

Re: The mvn script errors out when JAVA_HOME is not defined

Posted by Weiqi Gao <we...@gmail.com>.
On 8/7/06, Denis Cabasson <de...@insee.fr> wrote:
>
> Maven is juist checking that your JAVA_HOME is correctly set. It definitly
> needs to know where JAVA is installed.

The bin/mvn script only uses JAVA_HOME to compose JAVACMD, which is
later invoked.    It doesn't use it to do anything else.  And the
script explicitly attempts to guess where JAVA_HOME is when it is not
set.

> IMHO, there is no such thing as a "standard" location for Java....

I understand that.  But isn't the fact that the
/path/to/jdk1.5.0_12/bin directory is in the PATH enough?

> Denis.
>
>
> Weiqi Gao wrote:
> >
> > On 8/7/06, Vincent Siveton <vi...@gmail.com> wrote:
> >> JAVA_HOME is a requirement
> >> http://maven.apache.org/download.html#installation
> >
> > That piece of documentation seems to be wrong.  By reading the script,
> > I certainly get the impression that the script is furiously trying to
> > figure out where my JAVA_HOME is when the JAVA_HOME environment is not
> > set.
> >
> > Right after the block of script I cited, there is another check for
> > JAVA_HOME and it gives a warning if JAVA_HOME is not set.
> >
> > If Maven is going to require the setting of JAVA_HOME anyway, all that
> > extra script are pointless.
> >
> > Of course I'm advocating that Maven not requiring me to set JAVA_HOME
> > if I have installed my JDK in the "standard" location (such as
> > C:\Program Files\Java\jdk1.5.0_12.).

-- 
Weiqi Gao (高为奇)
weiqigao@gmail.com
http://www.weiqigao.com/blog/

Re: The mvn script errors out when JAVA_HOME is not defined

Posted by Denis Cabasson <de...@insee.fr>.
Maven is juist checking that your JAVA_HOME is correctly set. It definitly
needs to know where JAVA is installed.

IMHO, there is no such thing as a "standard" location for Java....

Denis.


Weiqi Gao wrote:
> 
> On 8/7/06, Vincent Siveton <vi...@gmail.com> wrote:
>> JAVA_HOME is a requirement
>> http://maven.apache.org/download.html#installation
> 
> That piece of documentation seems to be wrong.  By reading the script,
> I certainly get the impression that the script is furiously trying to
> figure out where my JAVA_HOME is when the JAVA_HOME environment is not
> set.
> 
> Right after the block of script I cited, there is another check for
> JAVA_HOME and it gives a warning if JAVA_HOME is not set.
> 
> If Maven is going to require the setting of JAVA_HOME anyway, all that
> extra script are pointless.
> 
> Of course I'm advocating that Maven not requiring me to set JAVA_HOME
> if I have installed my JDK in the "standard" location (such as
> C:\Program Files\Java\jdk1.5.0_12.).
> 
> -- 
> Weiqi Gao (高为奇)
> weiqigao@gmail.com
> http://www.weiqigao.com/blog/
> 
> 

-- 
View this message in context: http://www.nabble.com/The-mvn-script-errors-out-when-JAVA_HOME-is-not-defined-tf2063191.html#a5685379
Sent from the Maven - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: The mvn script errors out when JAVA_HOME is not defined

Posted by Weiqi Gao <we...@gmail.com>.
On 8/7/06, Vincent Siveton <vi...@gmail.com> wrote:
> JAVA_HOME is a requirement
> http://maven.apache.org/download.html#installation

That piece of documentation seems to be wrong.  By reading the script,
I certainly get the impression that the script is furiously trying to
figure out where my JAVA_HOME is when the JAVA_HOME environment is not
set.

Right after the block of script I cited, there is another check for
JAVA_HOME and it gives a warning if JAVA_HOME is not set.

If Maven is going to require the setting of JAVA_HOME anyway, all that
extra script are pointless.

Of course I'm advocating that Maven not requiring me to set JAVA_HOME
if I have installed my JDK in the "standard" location (such as
C:\Program Files\Java\jdk1.5.0_12.).

-- 
Weiqi Gao (高为奇)
weiqigao@gmail.com
http://www.weiqigao.com/blog/

Re: The mvn script errors out when JAVA_HOME is not defined

Posted by Vincent Siveton <vi...@gmail.com>.
JAVA_HOME is a requirement
http://maven.apache.org/download.html#installation

Cheers,

Vincent

2006/8/7, Weiqi Gao <we...@gmail.com>:
> Hi,
>
> I'm learning Maven 2.0.4 and encountered an error when invoking the
> mvn script.  The following piece of script seems to be the cause of my
> error message:
>
> ========================================
> if [ -z "$JAVACMD" ] ; then
>  if [ -n "$JAVA_HOME"  ] ; then
>    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
>      # 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
> ========================================
>
> I don't have my JAVA_HOME set, so my JAVACMD has the value of "java"
> when the [ -x "$JAVACMD" ] check is done.  Naturally it failed because
> the file "java" doesn't exist in the current directory.
>
> It would make more sense to do the [ -x "$JAVACMD" ] check in the [ -n
> "JAVA_HOME" ] branch of the if statement in the previous block (when
> $JAVACMD is built up).
>
> Thanks,
> --
> Weiqi Gao (高为奇)
> weiqigao@gmail.com
> http://www.weiqigao.com/blog/
>