# Ant (the software tool- not the insect) question

**URL:** https://boards.straightdope.com/t/ant-the-software-tool-not-the-insect-question/389587
**Category:** Factual Questions
**Created:** [January 26, 2007, 5:43pm UTC](https://boards.straightdope.com/t/ant-the-software-tool-not-the-insect-question/389587 "2007-01-26T17:43:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ticker](https://avatars.discourse-cdn.com/v4/letter/t/d07c76/32.png) [@ticker](https://boards.straightdope.com/u/ticker)
#### Post date: [January 26, 2007, 5:43pm UTC](https://boards.straightdope.com/t/ant-the-software-tool-not-the-insect-question/389587/1 "2007-01-26T17:43:10Z")

</div>

Quickie for ANT users I hope:

How can I add an external ‘lib’ directory, identified by an environment variable, to a classpath in ant?

For example, suppose I have some jar files located in “C:\SomeThirdPartyStuff\lib” and have the environment variable THIRDPARTY\_HOME set to “C:\SomeThirdPartyStuff”

My project is located in “C:\MyProj” and I have build.xml in the root of that project which begins

```auto

<?xml version="1.0"?>
<project name="My Project" basedir=".">

```

I tried to set up a path thus:

```auto

	<!-- get access to environment variable -->
	<property environment="env" />

	<property name="class.root" value="classes" />

	<path id="project.class.path">
		<pathelement location="${class.root}" />

		<!-- Include jars in third party lib -->
		<fileset dir="${env.THIRDPARTY_HOME}\lib">
			<include name="*.jar" />
		</fileset>
	</path>

```

What happens is that the THIRDPARTY\_HOME environment variable gets added to the basedir, giving “C:\MyProj\C:\SomeThirdPartyStuff\lib” which is obviously not what is wanted. How can I get the correct path?

---

<div class="post-metadata">

### Author: ![ZipperJJ](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zipperjj/32/211_2.png) [@ZipperJJ](https://boards.straightdope.com/u/ZipperJJ)
#### Post date: [January 26, 2007, 6:38pm UTC](https://boards.straightdope.com/t/ant-the-software-tool-not-the-insect-question/389587/2 "2007-01-26T18:38:29Z")

</div>

I have no idea what ant is but it sounds like you need some sort of “mappath” command that will dynamically find the location of the folder.

Maybe that term (mappath) will help you in your search for an answer?
