Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / April 2005

Tip: Looking for answers? Try searching our database.

Apache Ant - classpath

Thread view: 
Oaf - 08 Apr 2005 08:00 GMT
Hello,

Apache Ant version 1.6.2

I have a problem with my Ant script. I create a classpath reference at
the start of the script, like this:

   <path id="classpath">
       <pathelement location="/myjar.jar"/>
       <pathelement location="/myotherjar.jar"/>
       <pathelement location="/my3rdjar.jar"/>
   </path>

... but when I reference this from one of the targets in the build
script (a JUnit test), it doesn't seem to be picking up the elements
in the reference.

I define the classpath in the target as below. I need to add
additional jars into the classpath at this point, so I use
<pathelement location=""/> to do this.

   <target name="test">
       <junit printsummary="no">
           <classpath>
               <pathelement path="${classpath}"/>
               <pathelement location="/myadditionaljar.jar"/>
           </classpath>
... etc...

When I try and run the target from the script, I get lots of
java.lang.NoClassDefFoundError exceptions - the classes which should
be included in the <classpath> reference.

I'm guessing that the line in error is <pathelement
path="${classpath}"/>, but I can't work out why. The online manual
offers no obvious solution.

If I replace the <pathelement path="${classpath}"/> line with a repeat
of the <pathelement location=""/> lines for the jars I defined at the
top of my script, it works without a problem.

Thanks for any assistance,

Oaf
Daniel Rohe - 08 Apr 2005 08:18 GMT
> Hello,
>
[quoted text clipped - 24 lines]
>            </classpath>
> ... etc...

Use <path refid="classpath" /> instead of <pathelement
path="${classpath}"/>.

Daniel
Oaf - 08 Apr 2005 14:48 GMT
> Use <path refid="classpath" /> instead of <pathelement
> path="${classpath}"/>.

Tried that, but I get an error message stating that I can't add
additional files to the reference. In my original message, I stated
that I needed to add an additional jar file to the existing classpath
when I ran the JUnit test.

Thanks,

Oaf
Daniel Rohe - 08 Apr 2005 18:07 GMT
<path id="compile.classpath">
 <pathelement location="/myjar.jar"/>
 <pathelement location="/myotherjar.jar"/>
 <pathelement location="/mythirdjar.jar"/>
</path>

<target name="test">
 <junit printsummary="no">
   <classpath>
     <path refid="compile.classpath"/>
     <pathelement location="/myadditionaljar.jar"/>
   <classpath>
 </junit>
</target>

I have such a snippet in my build-file too and it works. Maybe the name
"classpath" of your path-variable could produce an error could you check
this?

Daniel

>> Use <path refid="classpath" /> instead of <pathelement
>> path="${classpath}"/>.
[quoted text clipped - 7 lines]
>
> Oaf
Oaf - 11 Apr 2005 10:29 GMT
> I have such a snippet in my build-file too and it works. Maybe the name
> "classpath" of your path-variable could produce an error could you check
> this?

Yes, that's what the problem was - thanks.

Oaf


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.