9
我下面這個頁面中最簡單的指令:
http://ant.apache.org/manual/develop.html
然而,當我嘗試執行目標「主」我在NetBeans得到這個錯誤:
taskdef class dec102012.MyAntTask cannot be found using the classloader AntClassLoader[]
但這錯誤是沒有意義的,因爲我的擴展「任務」新的Java類看起來是這樣的:
package dec102012;
import org.apache.tools.ant.BuildException;
public class MyAntTask extends org.apache.tools.ant.Task{
private String msg;
// The method executing the task
public void execute() throws BuildException {
System.out.println(msg);
}
// The setter for the "message" attribute
public void setMessage(String msg) {
this.msg = msg;
}
}
在我的build.xml相關的部分看起來像:
<taskdef name="mytask" classname="dec102012.MyAntTask" classpath="dec102012"/>
<target name="main">
<mytask message="Hello World! MyVeryOwnTask works!"/>
</target>
刪除'classpath =「dec102012」' –
當我這樣做時,我得到相同的錯誤。 – user1068636