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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to