Solved

How to get the classpath from ant build file

Posted on 2008-06-13
5
1,693 Views
Last Modified: 2008-06-13
I have a ant build file as follows:
+++++++++++
<project name="test" basedir=".">
      <property name="lib.dir"           value="/data/java_library/ext"/>
      <path id="project.classpath">
            <fileset dir="${lib.dir}">
                  <include name="**/*.jar"/>
                  <include name="**/*.zip"/>
            </fileset>
      </path>
</project>
++++++++++++

I would to run something like:

MYCLASSPATH=`ant -q cp`

which should set the environment variable MYCLASSPATH to whatever is defined in the ant build file.

how can I do that?


DAvid
0
Comment
Question by:dportabella
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 21780924
See below:
<property name="cp" refid="project.classpath" />
<echo message="${cp}" />

Open in new window

0
 

Author Comment

by:dportabella
ID: 21781304
It works!
Thanks CEHJ.


If someone is interested, add this to the build.xml
++++++++
      <property name="cp" refid="project.classpath" />
      <target name="cp" description="Shows the classpath">
            <echo message="${cp}"/>
      </target>
++++++++
And then execute:
MYCLASSPATH=`ant -q cp | sed -n -e "s/     \[echo\] //p"`


DAvid
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 21781434
:-)

You might find it more convenient to do
      <property name="cp" refid="project.classpath" />
        <echo message="${cp}" file="cp.txt" />

Open in new window

0
 

Author Comment

by:dportabella
ID: 21781497
Thanks!

DAvid
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 21781588
And of course you could always print it from your app ;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question