aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes How to print classpath using ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How to print classpath using ant" Watch "How to print classpath using ant" New topic
Author

How to print classpath using ant

vn us
Ranch Hand

Joined: Dec 27, 2002
Posts: 33
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

Joined: Dec 27, 2002
Posts: 33
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

Joined: Jun 12, 2003
Posts: 74
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

Joined: Dec 27, 2002
Posts: 33
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

Joined: Jun 12, 2003
Posts: 74
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to print classpath using ant
 
Similar Threads
ant tomcat dist -wrong file structure specified
Ant xml script & javac + JAVA_HOME classpath
Trouble launching ant exec task
wsjspc ant task
Pre Compiling jsp