aspose file tools*
The moose likes Java in General and the fly likes Problem including external jar to build.xml file Ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem including external jar to build.xml file Ant" Watch "Problem including external jar to build.xml file Ant" New topic
Author

Problem including external jar to build.xml file Ant

Kacee Saxena
Ranch Hand

Joined: Mar 04, 2008
Posts: 54
Dear Friends,

I am not getting how to add external libraries to build file used by Ant. I want to use classes12.jar and ojdbc14.jar in my java code. But i dont know how to incldue them in the existing build.xml. Here is an excerpt of my build file :

<property name="dest.classpath" value="/usr/local/xml/xerces-j-2.0.1/bin/xercesImpl.jar /us
r/local/xml/xerces-j-2.0.1/bin/xmlParserAPIs.jar /opt/oracle/sol-9.2.0/jdbc/lib/classes12.zip /proje
ct/tpf95/oracle/classes12.zip /opt/oracle/sol-9.2.0/jdbc/lib/classes12.jar /opt/oracle/sol-9.2.0/jdb
c/lib/ojdbc14.jar"/>

<path id="local.xerces.classpath">
<fileset dir="/usr/local/xml/xerces-j-2.0.1/bin" id="xerces.jar">
<include name="xercesImpl.jar"/>
<exclude name="xmlParseAPIs.jar"/>
</fileset>
</path>


Do i need to include these jars in path element as well ? If yes , then how ? Also how to decide the syntax of path id ?
eg. <path id = "xx.yy.zz">

what should be xx,yy,zz ?

Any help would be highly appreciable.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

I am not sure why you are using a property - that won't do anything unless you refer to that property later when declarinf a path.

The id for path is anything - it is a name that you can use later in the build script. Therefore, is is like a property name, but speciifc for use in paths, such as a classpath. This is generally true for every place where an id can be specified.

I usually set up classpaths using two mechanisms. For specific JAR files, I use 'pathelement location', but to grab all (or almost all) of the JARfiles within a directory (and its subdirectories) I use fileset. For example, if I want to define a classpath using all of the JAR files you mentioned in the dest.classpath property, I would use:



The above makes the assumption that only the JAR files list are in those directories. (I question the use of classes12.zip - that is an really old file if I recall correctly, but I left it in there to make the example complete.)

To use the above, in a later task I would use the dest.classpath:



By the way, I really recommend a book such as Ant In Action - I have a copy of the previous edition and it was invaluable.


JBoss In Action
Kacee Saxena
Ranch Hand

Joined: Mar 04, 2008
Posts: 54
Can you please provide the link for downloading this e-book ?
Kacee Saxena
Ranch Hand

Joined: Mar 04, 2008
Posts: 54
I already added those jar files using fileset and its working. Thanks for letting me know when to use path element and fileset. Thanks for the help
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Kacee, you can google Ant In Action as easily as I can...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem including external jar to build.xml file Ant