Hello Jason,

I have something similar to the following in my build.xml file:

<path id="myAll.class.path">
  <pathelement location="${someDir}/myFirst.jar"/>
   <pathelement location="${someDir}/mySecond.jar"/>
</path>

Then, inside the <java>  and    </java>  section, I have:
<classpath refid="myAll.class.path"/>

I hope this works for you... as I am still learning the ins and outs of ant 
build.xml files myself.

Thanks,
--Anna


-----Original message-----
From: astyrrian17 jason.pall...@lmco.com
Date: Tue, 20 Jan 2009 17:26:03 -0500
To: user@ant.apache.org
Subject: How do I reference external JARs when running a Java program fromAnt?

> 
> I have a java program that uses external jars (Apache POI files). I used
> eclipse to code this small program and it works just fine. This program
> referenced those external jars succesfully.
> 
> Now I want to use ant to run this program and provide inputs. I intend to
> compile, create the jar from ant, and then run it.
> 
> The program compiles, but I keep getting this following error:
> 
>      [java] Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apach
> e/poi/hssf/usermodel/HSSFWorkbook
> 
> I basically took the basic example code from here and tweaked it a bit:
> http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html#enhance
> 
> I tried using this, nested under both <javac> and <java>:
> 
> <classpath>
>    <pathelement location="C:/poi-3.2-FINAL-20081019.jar"/>
>    <pathelement location="C:/poi-contrib-3.2-FINAL-20081019.jar"/>
>    <pathelement location="C:/poi-scratchpad-3.2-FINAL-20081019.jar"/>
> </classpath>
> 
> I also tried putting this under the <manifest> tag of <jar>:
> 
> <attribute name="Class-Path" value="C:/poi-3.2-FINAL-20081019.jar
> C:/poi-contrib-3.2-FINAL-20081019.jar
> C:/poi-scratchpad-3.2-FINAL-20081019.jar"/>
> 
> Am I doing everything right? Should this work? How can I get those files
> included?
> 
> Thanks.


__________________________________________________________________________
This message and all attachments are PRIVATE, and contain information that
is PROPRIETARY to Intelligent Automation, Inc. You are not authorized to
transmit or otherwise disclose this message or any attachments to any
third party whatsoever without the express written consent of Intelligent
Automation, Inc. If you received this message in error or you are not
willing to view this message or any attachments on a confidential basis,
please immediately delete this email and any attachments and notify
Intelligent Automation, Inc.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to