ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy Lambert <anto...@gmx.de>
Subject Re: Java in JDK but ANT can't find it!
Date Mon, 21 Dec 2009 22:38:56 GMT
Hello Juha,

I do not understand what is causing the described problem to happen. The 
ant script never sets JAVA_HOME. At least not directly.

Can you check whether the rpm_mode is activated on your computer ?

I think you can run ant like that " ant --noconfig " to desactivate the 
rpm_mode.

Regards,

Antoine

Can you run the ant script like that : sh -x 
/home/jlaiho/aa/apache-ant-1.7.1/bin/ant 
to better find out what is happening >

Regards,

Antoine


Juha Laiho wrote:
> I came across this oldish thread while trying to resolve the same
> problem:
>
> David Nemer wrote:
> > I am running ANT programmatically in JAVA. So, my task is to build the
> > BUILD.XML.
> > I'm able to do so, but it throws an exception saying:
> >
> > /scratch2/nemer/test/xfire/build.xml:5: The following error occurred 
> while
> > executing this line:
> > /scratch2/nemer/test/xfire/build-common.xml:81: Unable to find a javac
> > compiler;
> > com.sun.tools.javac.Main is not on the classpath.
> > Perhaps JAVA_HOME does not point to the JDK.
> > It is currently set to "/opt/jdk1.6.0_06/jre"
>
>
> I think I have found an explanation on what is going on, at least
> for cases where ant is run using a shell script on the command line.
>
>
> Environment:
> Linux (Slackware)
> Java is Sun JDK 1.6.0_17-b04, from Slackware packages
>
> build.xml for the test:
> <project>
>   <echo message="JAVA_HOME: ${java.home}"/>
> </project>
>
> Environment variables, executable locations:
> bash-3.1$ echo $JAVA_HOME
> /usr/lib64/java
> bash-3.1$ echo $PATH
> /usr/lib64/java/bin:/usr/bin:/bin:/home/jlaiho/aa/apache-ant-1.7.1/bin
> bash-3.1$ type -a ant
> ant is /home/jlaiho/aa/apache-ant-1.7.1/bin/ant
> bash-3.1$ type -a java
> java is /usr/lib64/java/bin/java
>
> The installation pointed to by JAVA_HOME is a JDK installation
> (tools.jar does exist in $JAVA_HOME/lib). A JRE installation
> also exists, at $JAVA_HOME/jre .
>
> bash-3.1$ ls -l /usr/lib64/java/lib/tools.jar
> -rw-r--r-- 1 root root 12590684 2009-11-05 23:08 
> /usr/lib64/java/lib/tools.jar
>
> Running the test:
> bash-3.1$ ant
> Buildfile: build.xml
>      [echo] JAVA_HOME: /usr/lib64/java/jre
>
> BUILD SUCCESSFUL
> Total time: 0 seconds
>
> What happened? Explanation can be found in the ant shell script,
> starting at line 125 (at which point there hasn't been anything
> that would set JAVACMD):
>
> if [ -z "$JAVACMD" ] ; then
>   if [ -n "$JAVA_HOME"  ] ; then
>     # IBM's JDK on AIX uses strange locations for the executables
>     if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
>       JAVACMD="$JAVA_HOME/jre/sh/java"
>     elif [ -x "$JAVA_HOME/jre/bin/java" ] ; then
>       JAVACMD="$JAVA_HOME/jre/bin/java"
>     else
>       JAVACMD="$JAVA_HOME/bin/java"
>     fi
>   else
>     JAVACMD=`which java 2> /dev/null `
>     if [ -z "$JAVACMD" ] ; then
>         JAVACMD=java
>     fi
>   fi
> fi
>
> ... so, as JAVACMD was empty, and JAVA_HOME was set, AND
> $JAVA_HOME/jre/bin/java did exist, then the JAVA_HOME was
> forcible overridden with the JRE home directory. I don't
> understand why, but that is what happens.
>
> Is this a bug - perhaps? At least it's not what I would
> expect.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message