You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Fred Janon <fj...@yahoo.com> on 2008/03/04 01:09:27 UTC

Re: How to display the classpath that Ant is using to launch the java task?

Hi Garrett,

Thanks for the answer, the TopAntTips got the ansmwer for my problem.

Following up on my ant java target question, the "fork" option for
those who use ant to run java apps seem to be important when specifying
the classpath:

with fork='true' in the java target, here is the classpath as seen from
the app, it is the one from "app.classpath" in the build file as
desired:

     [java]
C:\Groovy-1.5.4\embeddable\groovy-all-1.5.4.jar;C:\Groovy_JPADownstream\classes;C:\Groovy_JPADownstream\lib\derby.jar;C:\Groovy_JPADownstr
eam\lib\derbyclient.jar;C:\Groovy_JPADownstream\lib\toplink-essentials-agent.jar;C:\Groovy_JPADownstream\lib\toplink-essentials.jar;C:\Groovy_JPADowns
tream\config

  <target name = "run" depends = "compile">
  <!-- CAUTION: MUST have the 'fork="true"' attribute, otherwise the
classpath of the application is the one from ant and JPA doesn't find
the persistence.xml file -->
    <java classname = "downstream.PopulateDownstream" fork="true">
        <classpath refid = "app.classpath"/>
    </java>
  </target>

with fork='false' in the java target. it is the one for "ant", not much
to do with the one specified in "app.classpath" in the build file:

     [java]
C:\ant-1.7.0\lib\ant-launcher.jar;C:\Groovy_JPADownstream\.;C:\Program
Files\Java\jre1.6.0_02\lib\ext\QTJava.zip;C:\ant-1.7.0\lib\ant-antl
r.jar;C:\ant-1.7.0\lib\ant-apache-bcel.jar;C:\ant-1.7.0\lib\ant-apache-bsf.jar;C:\ant-1.7.0\lib\ant-apache-log4j.jar;C:\ant-1.7.0\lib\ant-apache-oro.j
ar;C:\ant-1.7.0\lib\ant-apache-regexp.jar;C:\ant-1.7.0\lib\ant-apache-resolver.jar;C:\ant-1.7.0\lib\ant-commons-logging.jar;C:\ant-1.7.0\lib\ant-commo
ns-net.jar;C:\ant-1.7.0\lib\ant-jai.jar;C:\ant-1.7.0\lib\ant-javamail.jar;C:\ant-1.7.0\lib\ant-jdepend.jar;C:\ant-1.7.0\lib\ant-jmf.jar;C:\ant-1.7.0\l
ib\ant-jsch.jar;C:\ant-1.7.0\lib\ant-junit.jar;C:\ant-1.7.0\lib\ant-launcher.jar;C:\ant-1.7.0\lib\ant-netrexx.jar;C:\ant-1.7.0\lib\ant-nodeps.jar;C:\a
nt-1.7.0\lib\ant-starteam.jar;C:\ant-1.7.0\lib\ant-stylebook.jar;C:\ant-1.7.0\lib\ant-swing.jar;C:\ant-1.7.0\lib\ant-testutil.jar;C:\ant-1.7.0\lib\ant
-trax.jar;C:\ant-1.7.0\lib\ant-weblogic.jar;C:\ant-1.7.0\lib\ant.jar;C:\ant-1.7.0\lib\junit.jar;C:\ant-1.7.0\lib\xercesImpl.jar;C:\ant-1.7.0\lib\xml-a
pis.jar;C:\jdk1.6.0_02\lib\tools.jar

  <target name = "run" depends = "compile">
  <!-- CAUTION: MUST have the 'fork="true"' attribute, otherwise the
classpath of the application is the one from ant and JPA doesn't find
the persistence.xml file -->
    <java classname = "downstream.PopulateDownstream" fork="false">
        <classpath refid = "app.classpath"/>
    </java>
  </target>

I don't really understand why for='true' is not the default for the
java target in ant but that's how it is.

Conclusion: make sure that 'fork="true"' is set on a java target in Ant
is you want to use your own classpath and not the Ant one.

Fred

--- Garrett Smith <dh...@gmail.com> wrote:

> On Tue, Feb 26, 2008 at 6:38 PM, Fred Janon <fj...@yahoo.com> wrote:
> > Is there anything to display the classpath that Ant is using to
> launch
> >  a java task besides the verbose and debug ant options that don't
> >  display it?
> >
> This might not be the answer to what you want to do, but...
> 
> Ant should be using PATH, variable.
> 
> Are you using Windows? If so...
> Start -> Control Panel...
> Double click on "System"...
> In the System Properties, choose "Advanced" tab.
> Click "Environment Variables" button
> set system properties.
> 
> If JAVA_HOME is in "Program Files", change that to
> C:\Progra~1\Java\...
> 
> I know it's not exactly what you asked, but thought it might help
> anyway.
> 
> This might help, too:
> http://www.catalysoft.com/articles/TopAntTips.html
> 
> Garrett
> 
> >  How can I debug Ant file in general? I check the Ant manual left
> and
> >  right and didn't find anything.
> >
> >  Thanks
> >
> >  Fred
> >
> >
> > 
> ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >  For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 


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


Re: How to display the classpath that Ant is using to launch the java task?

Posted by Fred Janon <fj...@yahoo.com>.
Hi Steve,

Thanks for the explanation. It still would save some head scratching
and $$$ (I spent almost a whole day trying to get my ant file running)
if the fork option documentation was a bit expanded.

Cheers,

Fred

--- Steve Loughran <st...@apache.org> wrote:

> Fred Janon wrote:
> > Hi Garrett,
> > 
> > Thanks for the answer, the TopAntTips got the ansmwer for my
> problem.
> > 
> > Following up on my ant java target question, the "fork" option for
> > those who use ant to run java apps seem to be important when
> specifying
> > the classpath:
> > 
> > with fork='true' in the java target, here is the classpath as seen
> from
> > the app, it is the one from "app.classpath" in the build file as
> > desired:
> > 
> >      [java]
> >
>
C:\Groovy-1.5.4\embeddable\groovy-all-1.5.4.jar;C:\Groovy_JPADownstream\classes;C:\Groovy_JPADownstream\lib\derby.jar;C:\Groovy_JPADownstr
> >
>
eam\lib\derbyclient.jar;C:\Groovy_JPADownstream\lib\toplink-essentials-agent.jar;C:\Groovy_JPADownstream\lib\toplink-essentials.jar;C:\Groovy_JPADowns
> > tream\config
> > 
> >   <target name = "run" depends = "compile">
> >   <!-- CAUTION: MUST have the 'fork="true"' attribute, otherwise
> the
> > classpath of the application is the one from ant and JPA doesn't
> find
> > the persistence.xml file -->
> >     <java classname = "downstream.PopulateDownstream" fork="true">
> >         <classpath refid = "app.classpath"/>
> >     </java>
> >   </target>
> > 
> > with fork='false' in the java target. it is the one for "ant", not
> much
> > to do with the one specified in "app.classpath" in the build file:
> > 
> >      [java]
> >
>
C:\ant-1.7.0\lib\ant-launcher.jar;C:\Groovy_JPADownstream\.;C:\Program
> > Files\Java\jre1.6.0_02\lib\ext\QTJava.zip;C:\ant-1.7.0\lib\ant-antl
> >
>
r.jar;C:\ant-1.7.0\lib\ant-apache-bcel.jar;C:\ant-1.7.0\lib\ant-apache-bsf.jar;C:\ant-1.7.0\lib\ant-apache-log4j.jar;C:\ant-1.7.0\lib\ant-apache-oro.j
> >
>
ar;C:\ant-1.7.0\lib\ant-apache-regexp.jar;C:\ant-1.7.0\lib\ant-apache-resolver.jar;C:\ant-1.7.0\lib\ant-commons-logging.jar;C:\ant-1.7.0\lib\ant-commo
> >
>
ns-net.jar;C:\ant-1.7.0\lib\ant-jai.jar;C:\ant-1.7.0\lib\ant-javamail.jar;C:\ant-1.7.0\lib\ant-jdepend.jar;C:\ant-1.7.0\lib\ant-jmf.jar;C:\ant-1.7.0\l
> >
>
ib\ant-jsch.jar;C:\ant-1.7.0\lib\ant-junit.jar;C:\ant-1.7.0\lib\ant-launcher.jar;C:\ant-1.7.0\lib\ant-netrexx.jar;C:\ant-1.7.0\lib\ant-nodeps.jar;C:\a
> >
>
nt-1.7.0\lib\ant-starteam.jar;C:\ant-1.7.0\lib\ant-stylebook.jar;C:\ant-1.7.0\lib\ant-swing.jar;C:\ant-1.7.0\lib\ant-testutil.jar;C:\ant-1.7.0\lib\ant
> >
>
-trax.jar;C:\ant-1.7.0\lib\ant-weblogic.jar;C:\ant-1.7.0\lib\ant.jar;C:\ant-1.7.0\lib\junit.jar;C:\ant-1.7.0\lib\xercesImpl.jar;C:\ant-1.7.0\lib\xml-a
> > pis.jar;C:\jdk1.6.0_02\lib\tools.jar
> > 
> >   <target name = "run" depends = "compile">
> >   <!-- CAUTION: MUST have the 'fork="true"' attribute, otherwise
> the
> > classpath of the application is the one from ant and JPA doesn't
> find
> > the persistence.xml file -->
> >     <java classname = "downstream.PopulateDownstream" fork="false">
> >         <classpath refid = "app.classpath"/>
> >     </java>
> >   </target>
> > 
> 
> 
> When you don't fork, the classpath of the java process should be
>   -the classpath you set
>   -java.*, javax.* and some bits of org.omg.*, org.w3c.*  sun.* that
> are 
> part of the de-facto JVM API.
> If the ant stuff is being seen, it could be that the app.classpath
> has 
> somehow pulled them in.
> Your code runs under a security manager that catches calls to 
> System.exit(), so only your app exits, not the JVM.
> 
>  > I don't really understand why for='true' is not the default for
> the
>  > java target in ant but that's how it is.
> 
> 
> Historically, because it made things faster to run. Most of Ant's own
> 
> tasks <javac> etc. are bits of java code running in-JVM. Also, in-JVM
> 
> code picks up ANT's proxy and memory settings automatically; makes 
> customisation easier.
> 
>  > Conclusion: make sure that 'fork="true"' is set on a java target
> in Ant
>  > is you want to use your own classpath and not the Ant one.
> 
> -- 
> Steve Loughran                 
> http://www.1060.org/blogxter/publish/5
> Author: Ant in Action           http://antbook.org/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 


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


Re: How to display the classpath that Ant is using to launch the java task?

Posted by Steve Loughran <st...@apache.org>.
Fred Janon wrote:
> Hi Garrett,
> 
> Thanks for the answer, the TopAntTips got the ansmwer for my problem.
> 
> Following up on my ant java target question, the "fork" option for
> those who use ant to run java apps seem to be important when specifying
> the classpath:
> 
> with fork='true' in the java target, here is the classpath as seen from
> the app, it is the one from "app.classpath" in the build file as
> desired:
> 
>      [java]
> C:\Groovy-1.5.4\embeddable\groovy-all-1.5.4.jar;C:\Groovy_JPADownstream\classes;C:\Groovy_JPADownstream\lib\derby.jar;C:\Groovy_JPADownstr
> eam\lib\derbyclient.jar;C:\Groovy_JPADownstream\lib\toplink-essentials-agent.jar;C:\Groovy_JPADownstream\lib\toplink-essentials.jar;C:\Groovy_JPADowns
> tream\config
> 
>   <target name = "run" depends = "compile">
>   <!-- CAUTION: MUST have the 'fork="true"' attribute, otherwise the
> classpath of the application is the one from ant and JPA doesn't find
> the persistence.xml file -->
>     <java classname = "downstream.PopulateDownstream" fork="true">
>         <classpath refid = "app.classpath"/>
>     </java>
>   </target>
> 
> with fork='false' in the java target. it is the one for "ant", not much
> to do with the one specified in "app.classpath" in the build file:
> 
>      [java]
> C:\ant-1.7.0\lib\ant-launcher.jar;C:\Groovy_JPADownstream\.;C:\Program
> Files\Java\jre1.6.0_02\lib\ext\QTJava.zip;C:\ant-1.7.0\lib\ant-antl
> r.jar;C:\ant-1.7.0\lib\ant-apache-bcel.jar;C:\ant-1.7.0\lib\ant-apache-bsf.jar;C:\ant-1.7.0\lib\ant-apache-log4j.jar;C:\ant-1.7.0\lib\ant-apache-oro.j
> ar;C:\ant-1.7.0\lib\ant-apache-regexp.jar;C:\ant-1.7.0\lib\ant-apache-resolver.jar;C:\ant-1.7.0\lib\ant-commons-logging.jar;C:\ant-1.7.0\lib\ant-commo
> ns-net.jar;C:\ant-1.7.0\lib\ant-jai.jar;C:\ant-1.7.0\lib\ant-javamail.jar;C:\ant-1.7.0\lib\ant-jdepend.jar;C:\ant-1.7.0\lib\ant-jmf.jar;C:\ant-1.7.0\l
> ib\ant-jsch.jar;C:\ant-1.7.0\lib\ant-junit.jar;C:\ant-1.7.0\lib\ant-launcher.jar;C:\ant-1.7.0\lib\ant-netrexx.jar;C:\ant-1.7.0\lib\ant-nodeps.jar;C:\a
> nt-1.7.0\lib\ant-starteam.jar;C:\ant-1.7.0\lib\ant-stylebook.jar;C:\ant-1.7.0\lib\ant-swing.jar;C:\ant-1.7.0\lib\ant-testutil.jar;C:\ant-1.7.0\lib\ant
> -trax.jar;C:\ant-1.7.0\lib\ant-weblogic.jar;C:\ant-1.7.0\lib\ant.jar;C:\ant-1.7.0\lib\junit.jar;C:\ant-1.7.0\lib\xercesImpl.jar;C:\ant-1.7.0\lib\xml-a
> pis.jar;C:\jdk1.6.0_02\lib\tools.jar
> 
>   <target name = "run" depends = "compile">
>   <!-- CAUTION: MUST have the 'fork="true"' attribute, otherwise the
> classpath of the application is the one from ant and JPA doesn't find
> the persistence.xml file -->
>     <java classname = "downstream.PopulateDownstream" fork="false">
>         <classpath refid = "app.classpath"/>
>     </java>
>   </target>
> 


When you don't fork, the classpath of the java process should be
  -the classpath you set
  -java.*, javax.* and some bits of org.omg.*, org.w3c.*  sun.* that are 
part of the de-facto JVM API.
If the ant stuff is being seen, it could be that the app.classpath has 
somehow pulled them in.
Your code runs under a security manager that catches calls to 
System.exit(), so only your app exits, not the JVM.

 > I don't really understand why for='true' is not the default for the
 > java target in ant but that's how it is.


Historically, because it made things faster to run. Most of Ant's own 
tasks <javac> etc. are bits of java code running in-JVM. Also, in-JVM 
code picks up ANT's proxy and memory settings automatically; makes 
customisation easier.

 > Conclusion: make sure that 'fork="true"' is set on a java target in Ant
 > is you want to use your own classpath and not the Ant one.

-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

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