Hi authors
The java program viz.ChapterAntProject.java shown in the page 582 seems to be having some errors since the code after compilation ok.does not create a build.xml as indicated.The codes are shown for your correction
Code:
package org.apache.tools.ant;
import java.util.ArrayList;
import java.lang.String;
import java.lang.Class;
import org.apache.tools.ant.listener.Log4jListener;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.util.SourceFileScanner;
import org.apache.tools.ant.Launcher;
import org.apache.tools.ant.Target;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Main;
import org.apache.tools.ant.XmlLogger;
import org.apache.tools.ant.AntClassLoader;
public class ChapterAntProject extends org.apache.tools.ant.Project{
public void ChapterAntProjectinit()
{
super.init();
}
public static void main(String[] args)
{
ChapterAntProject proj1=new ChapterAntProject();
Project proj=new Project();
try
{
/*
Create the project object and add custom tag
*/
proj.setName("jomsproject");
GreetJon task=new GreetJon();
proj.addTaskDefinition("jonstask",task.getClass());
/*
create the Target Object as a child ofparent and addthe Task to it
*/
Target targ=new Target();
targ.setName("jonstarget");
targ.addTask(task);
proj.addTarget("jonstarget" , targ);
proj.setDefaultTarget("jonstarget");
/*
Execute the Target
*/
proj.executeTarget("jonstarget");
}
catch(Exception e)
{
};
}
}
class GreetJon extends Task{
public GreetJon(){
;}
public void execte() throws BuildException{
System.out.println("Hello ");
}
}
***********************************
Error: Could not find or load main class org.apache.tools.ant.ChapterAntProject
****************************************
Shall be thankful if the same is corrected to produce results
Thanks
Cheers
muthukutta1