Hello,
  
  I am posting to this group since I am not getting any guidance apart 
from 
  "look at ant source code".
  
  I am trying to use ant programmatically using the Ant API.
  
  When executing the code
    it throws NullPointerException for the line
    
    tinstaller.setClasspath(class_path); 
    
    in the code.
    It is for the class  "org.apache.tools.ant.taskdefs.Taskdef;"
    But for the other taskdefs e.g. Javac its O.K.
    Is there any problem to load classpath in Taskdef object?
    If not then where's the wrong with the code? 
    The Exception
    
    Exception in thread "main" java.lang.NullPointerException
            at 
  org.apache.tools.ant.taskdefs.DefBase.setClasspath(DefBase.java:90)
            at Installer.main(Installer.java:35)
    
    Code
    
    
    
    import org.apache.tools.ant.BuildException;
    import org.apache.tools.ant.launch.Locator;
    import org.apache.tools.ant.taskdefs.Taskdef;
    import org.apache.tools.ant.Project;
    import org.apache.tools.ant.types.Path;
    import com.izforge.izpack.ant.*;
    
    public class Installer  {
       
       public static void main(String args[]) {
                
                Project p = new Project();
                p.init();
                p.setName("Building");
                p.setDefault("installer") ;
                p.setBasedir(".");
                
                
                  org.apache.tools.ant.types.Path class_path = new  
  org.apache.tools.ant.types.Path(p);             
                 
  
class_path.setPath("C:/Bishwakarma/BuildTemp/lib/standalone-compiler.jar");     
                      
                  org.apache.tools.ant.taskdefs.Taskdef tinstaller = 
new  
  org.apache.tools.ant.taskdefs.Taskdef();
                tinstaller.setProject(p);
                tinstaller.setTaskName("izpack");
                
                tinstaller.setClasspath(class_path); 
                
                
  tinstaller.setClassname("com.izforge.izpack.ant.IzPackTask");
                tinstaller.execute();
                
            }
            
            
        }
    
    Any suggestion will be highly appreciated.
    
    Warm Regards
    Subir
  
                                
---------------------------------
 Do you have a question on a topic you cant find an Answer to. Try Yahoo! 
Answers India
 Get the all new Yahoo! Messenger Beta Now

Reply via email to