I’m trying to run a custom java task using ant with the custom task already successfully complied into the .class file. This custom task will call another class in an application, in theory running that program via command line.
<?xml version="1.0"?>
<project default="main" name="myproject">
<property name="distDir" location=".\dist\" />
<property name="mainDir" location=".\" />
<property name="host" value=""/>
<property name="port" value=""/>
<property name="dir" value=""/>
<property name="startTest" value=""/>
<property name="endTest" value=""/>
<property name="testOnly" value=""/>
<property name="userName" value=""/>
<property name="passwd" value=""/>
<taskdef name="mytask" classname="Classrunner">
<classpath>
<fileset dir="${distDir}>
<includes="*.jar">
</fileset>
</classpath>
</taskdef>
<target name="main">
<mytask host="${host}" port="${port}" dir="${dir}" startTest="${startTest}" endTest="${endTest}" testOnly="${testOnly}" userName="${userName}" passwd="${passwd}"/>
</target>
</project>
The taskdef part of my ant file specifies a fileset that contains a directories that has all the jars in it to run application I’m trying to run. The problem I’m running into is whenever I invoke ant via the command line and pass all the right parameters, and then I get an error saying “java.lang.NoClassDefFoundError: com/pega/fuzz/player/CustomClass”
CustomClass is the class that I call in my custom file and it exists inside that directory of all the jar files so I’m not sure how to specify where it lives since Ant can’t find it.
Someone at work helped me figure out a way to fix this.
The best way is if you set the environment variable, classpath, through a .bat file like so:
From there you can then set a variable for ant and run your ant file right from here.