score:32
you can provide full path to the ant-contrib jar explicitly using "classpath" element:
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${path-to-ant-contrib}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
edit: link contributed by djacomo
:
score:0
check you have read permissions for the ant-contrib jar file.
in our case after copying the file with another user it did not, giving the same error message.
score:1
use the below mentioned code in your build xml:
<path id="ant.classpath">
<pathelement location="${ant.jarpath}/ant.jar" />
<pathelement location="${ant.jarpath}/ant-contrib-0.3.jar" />
</path>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath refid="ant.classpath" />
</taskdef>
and in your build property file:
ant.jarpath=d:/antjars
and place ant.jar and ant-contrib-0.3.jar in directory:d:/antjars
score:2
it would appear that you haven't installed the ant contrib jar into the correct lib directory. this can be difficult to do if you have several installations of ant.
my suggestion is to install your ant plugins into the "$home/.ant/lib" directory. you could go one step further and automate the process as follows:
<project name="ant-contrib-tasks" default="all">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<target name="bootstrap">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/ant-contrib.jar" src="http://search.maven.org/remotecontent?filepath=ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
</target>
<target name="all">
<for param="file">
<fileset dir="." includes="*.txt"/>
<sequential>
<echo message="found file @{file}"/>
</sequential>
</for>
</target>
</project>
score:6
i fixed that this way:
add the jar to the ant runtime classpath entries.
window>preferences>ant>runtime>classpath
add the jar to either ant home entries or global entries.
score:8
one important thing missing from this stackoverflow page is that setting the correct ant_home env var is absolutely vital and important, without this setting ant keeps telling the same error, regardless of where you copy the ant-contrib-1.0b3.jar on your file systems. this missing thing has costed me a few hours. =)
however i receive this error without eclipse, in the pure ant.
Source: stackoverflow.com
Related Query
- Getting an error "Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found."
- Could not load definitions from resource flexTasks.tasks. It could not be found
- I have recently converted my project to maven. But have an error Resource read error: Could not load com/sun/xml/txw2/Content.class
- After converting to maven getting error : Could not find or load main class
- In Eclipse, why am I getting the error "Error: Could not find or load main class Coordinator.java"?
- false error from Eclipse: Function '__android_log_print' could not be resolved (Android, CDT)
- Eclipse could not resolve string resource error
- Eclipse : Getting Error as Could not find jar file while installing Plugin in Eclipse
- org.hibernate.InvalidMappingException: Could not parse mapping document from resource *.hbm.xml
- from scipy.linalg import _fblas: ImportError: DLL load failed: The specified module could not be found
- Using SVNAnt in eclipse Build Failed (Could not load definitions from resource)
- Getting the following error " The build could not read 1 project and Non resolvablle parent error" when down mvn clean install
- Getting and error “Cannot complete the install because one or more required items could not be found” in oomp installer
- Error running cucumber in eclipse- Could not find or load main class cucumber.api.cli.Main
- Getting and error "Cannot complete the install because one or more required items could not be found" in oomp installer
- Error When Compiling on Eclipse Luna with JavaCC - Could not find or load main class javacc
- Trying to run a java program in console will give a could not find or load main class error
- Getting error "HTTP Status 404" -" The requested resource is not available" when running a web application?
- no .apk is created when running the project after getting the error could not find apk
- error could not find or load main class -eclipse?
- Gradle build error in eclipse: Could not find or load main class Files\OpenJdk11\lib\security\cacerts
- Getting "Error: Could not find or load main class aQute.launcher.Launcher" in Eclipse IDE even though it works in command line
- I am getting an error in ecllipse that a class is missing from Jar and the class is not the JAR , what can be done in this case?
- Could not find or load main class- I cannot run my .jar file created from Ant
- Error : Could not find or load main class JavaFundamentals.GUIOutput
- how can i fix this error "Error: Could not find or load main class" in eclipse?
- when my system changed maven project giving error Error: Could not find or load main class
- Java I am getting an "Error: Could not find or load main class" for everything in cdm prompt Windows 7
- org.hibernate.InvalidMappingException: Could not parse mapping document from resource houseDocumenter/House.hbm.xml
- could not load the tomcat server error
More Query from same tag
- How to create a background method which waits for an input signal? (beginner java)
- Action into Submenu Context Menu Java JFace SWT Eclipse
- Where should I add servlets in the Eclipse IDE's new folder structure
- DatastoreServiceFactory ClassNotFoundException (running the appengine local server)
- Mapping servlet in web.xml
- Eclipse Pydev: Run selected lines of code
- Gradle Build export error in Android ADT
- Using CHelper plugin in IntelliJ for a coding contest
- Error transferring file: Connection timed out: connect in maven.
- Create a .app with python in eclipse?
- How to convert the installation of eclipse from eclipse for java developer to eclipse for EE developers?
- Why eclipse doesn't recompile last changes made to my Java classes?
- Open JDK crashing eclipse
- Missing R.java on Linux Eclipse Android project
- Determining if an offset is in between line numbers?
- LuaSocket in Windows - How to install and use it in an Eclipse Project
- Rotate text (not an image) in Android
- Including a file in the Eclipse RCP bundle working directory
- Running a specific project when I hit Run in eclipse
- Perl Script to run Junit test cases and unistall apk
- How to find where a specific project is stored | Eclipse
- eclipse E4\eclipse 3.6 debuging java script with rhino
- Inproper Storage of Elements in Class Object Array
- Eclipse is not loading?
- Button properties changes doesn't save after screen rotate
- How to connect Codeigniter API to an Android App
- How To Debug Legacy GWT Code With Eclipse
- Make Strobe Light from LED light on button click
- Unable to use Java 1.8
- Jersey Services with Tomcat and Eclipse