• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to print classpath using ant

 
vn us
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would like to print the classpath using the ant tool.
OS is Windows
One of the sample program that i got from the default sunone sample program is running but I would like to see what are all the jar files that program is using.
I'm not able to find a ant tag name to print the classpath
I used <exec and <apply tags to print the %classpath% but got the following error
part of ant build file
<target name="print">
<exec executable="echo %classpath% ">
</exec><\target>
I got the following error
C:\Sun\AppServer7\samples\xml\sax\src\build.xml:46: Execute failed: java.io.IOEx
ception: CreateProcess: ls C:\Sun\AppServer7\samples\xml\sax\src\build.xml error=2
OS that I'm using is Widnows
Please through some light on this.

Regards,
VN
 
vn us
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to resolve in a different way ( this is not what i was looking for ), but it served the purpose, but I feel this is not the right way.
Enable the debug for the ant tool which will give all the details ( what ant tool is doing ) including the classpath values.

Cheers,
VN
 
Peter Storch
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about that:
<property environment="env"/>
<echo message="CLASSPATH = ${env.CLASSPATH}"/>

or the predefined properties ${java.class.path} or ${classpath} serve as well.
 
vn us
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
some how this option is not working for me.
As echo is printing the text as it is and more over on Windows $ doesn't mean any thing for the env variables, pls. correct me if I'm wrong.
XML is
<target name="print" >
<property environment="env"/>
<echo message="CLASSPATH = ${env.CLASSPATH}"/>
</target>
Output is
print:
[echo] CLASSPATH = ${env.CLASSPATH}
The above config is not working
Please note that the OS is Windows

Thanks,
VN
 
Peter Storch
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vn us:
...more over on Windows $ doesn't mean any thing for the env variables, pls. correct me if I'm wrong.

Sure, the $ is an ANT thing. With ${VARIABLE_NAME} you can refere to variables (properties) within ANT scripts.
can you try to put this
<property environment="env"/>
directly under the <project...> element.

At the moment I'm not quite sure if ANT is expanding the variables in the message attribute of the echo element.
What about this:
<echo>CLASSPATH = ${env.CLASSPATH}</echo>
[ October 05, 2003: Message edited by: Peter Storch ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic