I am trying to write java code to use the API rather than writing a build.xml.I am doing this for testing purpose so i have hardcoded. The following line in the code throws NullPointerException while executing the code.The class_path is of type Path.But while converting class_path to String and printing that i get a value. tinstaller.setClasspath(class_path); I am saying that the method setClasspath of org.apache.tools.ant.taskdefs.Taskdef not getting the class_path while the method setClasspath of org.apache.tools.ant.taskdefs.Javac not throwing NullPointerException. Subir
"Anderson, Rob (Global Trade)" <[EMAIL PROTECTED]> wrote: I'm not sure what you are trying to do with this code, or what the context is. Where are you wrong? To start with, you have hardcoded a lot of things into your code. Are you trying to write java code to use the API rather than writing a build.xml? -Rob A > -----Original Message----- > From: subir bhaumik [mailto:[EMAIL PROTECTED] > Sent: Tuesday, May 16, 2006 6:44 AM > To: user@ant.apache.org > Subject: Taskdef > > Hi > While i am executing the following the method > setClasspath of Taskdef getting NullPointerException, But > the same method for Javac is O.K. > > Where i am wrong? > > My Code > > > > String base_dir = Host.getBuildTemp(); > > Project p = new Project(); > p.setName("Building"); > p.setDefault("installer") ; > p.setBasedir("."); > > //org.apache.tools.ant.types.Reference > compile_class_path = new > org.apache.tools.ant.types.Reference(p,"compile_class_path"); > > org.apache.tools.ant.types.Path class_path = > new org.apache.tools.ant.types.Path(p); > > org.apache.tools.ant.types.FileSet fs = new > org.apache.tools.ant.types.FileSet(); > File lib = new File(base_dir+"/"+"lib"); > fs.setDir(lib); > fs.setIncludes("*.jar"); > class_path.addFileset(fs); > > > org.apache.tools.ant.taskdefs.Taskdef > tinstaller = new org.apache.tools.ant.taskdefs.Taskdef(); > tinstaller.setProject(p); > tinstaller.setTaskName("izpack"); > String cp=class_path.toString(); > System.out.println("File Addition"+cp); > tinstaller.setClasspath(class_path); > //NullPointerException > System.out.println("File Test1"); > > tinstaller.setClassname("com.izforge.izpack.ant.IzPackTask"); > System.out.println("File Addition"+cp); > IzPackTask izpack = new IzPackTask(); > System.out.println("File Test2"); > izpack.setInput("D:/subir/install.xml"); > izpack.setOutput("D:/subir/out.jar"); > System.out.println("Test3"); > izpack.setBasedir("."); > Target installer = new Target(); > installer.setName("installer"); > > installer.addTask(tinstaller); > installer.addTask(izpack); > //System.out.println(compile.toString()); > > p.addTarget(installer); > DefaultLogger consoleLogger = new DefaultLogger(); > consoleLogger.setErrorPrintStream(System.err); > consoleLogger.setOutputPrintStream(System.out); > consoleLogger.setMessageOutputLevel(Project.MSG_INFO); > p.addBuildListener(consoleLogger); > > > Warm Regards > > Subir > > > --------------------------------- > Why was V. Sehwag warned by the BCCI? Share your knowledge > on Yahoo! Answers India Send instant messages to your online > friends - NOW > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------- Why was V. Sehwag warned by the BCCI? Share your knowledge on Yahoo! Answers India Send instant messages to your online friends - NOW