I am defining a new task in Ant. I exported it as a jar and added to my buildfile:
<taskdef classname="X" classpath="Y.jar"/>
The problem is that this fails at runtime. It tells me it didn't find the class. By adding the jar to the classpath, it is corrected.
My question is: Is there a way that I can refer to my jar from the Ant buildfile, without changing the classpath?
CLASSPATH
environment variable, don't. Delete it from your environment setup, and get into the habit of specifying classpaths explicitly. Because otherwise, you'll find yourself with a hard-to-debug problem where a library gets loaded from your classpath and you don't expect it. Or someone else can't run your code because s/he doesn't have the sameCLASSPATH
environment variable. – Bysshe