0

Hello friends ,
I am new to ant tasks.in this custom ant tasks I have tried to implement, there are two classes HelloWorld.java and CmdCompile.java.

this is the build.xml I use,

<?xml version="1.0" ?>

<project name="Antcompile" default="main" basedir=".">
    <!--<description>Builds, tests, and runs the project Antcompile.</description>-->
    <import file="nbproject/build-impl.xml"/>
	
	
	
	<taskdef name="hello" 	 classname="just.inside.HelloWorld"/>
	<taskdef name="builder"  classname="just.inside.CmdCompile"/>

   		
		<target name="main" >
			<hello what="miraj my son"/>
			
          <builder process="C:/Program Files (x86)/Windows Media Player/wmplayer.exe" />
        </target>
		
	
		
    
</project>

I keep getting the error

BUILD FAILED
C:\Documents and Settings\Administrator\Desktop\just\Antcompile\Antcompile\build
.xml:9: taskdef class just.inside.HelloWorld cannot be found
using the classloader AntClassLoader[]

any help appreciated. (java classes are attached)

Attachments
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package just.inside;
import java.util.*;
import java.io.*;
//import com.ifs.rnd.harvest.*;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
/**
 *
 * @author Administrator
 */
public class CmdCompile extends Task {

    private String process;

    public void setProcess(String process) {
        this.process = process;
    }

    public void execute()throws BuildException{
     try {
                Runtime rt = Runtime.getRuntime();
                //Process pr = rt.exec("cmd /c dir");
                Process pr = rt.exec(process);

                BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));

                String line=null;

                while((line=input.readLine()) != null) {
                    System.out.println(line);
                }

                int exitVal = pr.waitFor();
                System.out.println("Exited with error code "+exitVal);

            } catch(Exception e) {
                System.out.println(e.toString());
                e.printStackTrace();
            }
    }

}
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package just.inside;
//package com.ifs.rnd.harvest;
import java.util.*;
import java.io.*;
//import com.ifs.rnd.harvest.*;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

/**
 *
 * @author Administrator
 */
public class HelloWorld extends Task{

    private String what;

    public void setWhat(String what) {
        this.what = what;
    }

    public void execute(){

      System.out.println("Hello "+what);

    }

}
2
Contributors
1
Reply
4
Views
6 Years
Discussion Span
Last Post by ~s.o.s~
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.