Posted By:
Ramkumar_Menon
Posted On:
Wednesday, July 25, 2007 02:15 PM
I am trying to execute an ant task using Java. I receive a NoClassDefFoundError as mentioned in the subject of this message. I have ensured that I have tools.jar in my classpath. Any clues on what could be going on ? Here is the snippet I used to run the ant task. File buildFile = new File(projectDir + File.separator + "build.xml"); Project p = new Project(); Iterator it = envProperties.entrySet().iterator(); while(it.hasNext()) { Map.Entry entry = (Map.Entry)it.next(); p.setProperty("env." + entry.getKey(),"" + entry.getValue()); } p.setUserProperty("param1",x1); p.setUserProperty("param2"
More>>
I am trying to execute an ant task using Java. I receive a NoClassDefFoundError as mentioned in the subject of this message.
I have ensured that I have tools.jar in my classpath.
Any clues on what could be going on ?
Here is the snippet I used to run the ant task.
File buildFile = new File(projectDir + File.separator + "build.xml");
Project p = new Project();
Iterator it = envProperties.entrySet().iterator();
while(it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();
p.setProperty("env." + entry.getKey(),"" + entry.getValue());
}
p.setUserProperty("param1",x1);
p.setUserProperty("param2",x2);
p.setUserProperty("param3",x3);
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
DefaultLogger consoleLogger = new DefaultLogger();
consoleLogger.setErrorPrintStream(System.err);
consoleLogger.setOutputPrintStream(System.out);
consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
p.addBuildListener(consoleLogger);
p.executeTarget(p.getDefaultTarget());
<<Less