Skip to main content

Launching Ant Inside Java Program

Most of the time, we need to embed Ant in a java program. So if you need to call Ant task inside Java program, this piece of code will do it.

Required Jars:

Ant.jar
Ant-Launcher.jar
tools.jar*


you can get the jar file by just using the class org.apache.tools.ant.launch.Launche through this Jar finder Website


Source Code:

import org.apache.tools.ant.launch.Launcher;

public class LaunchAnt
{
public static void main(String args[])
{
String[] parameters = new String[2];

parameters[0]="-buildfile";

parameters[1] = "build.xml";

Launcher.main(parameters);

}

}


Note:
tools.jar will be available at the location

C:\ProgramFiles\ - Windows

usr/lib/jvm/ - Linux


Install Java in Linux

Comments

Anonymous said…
Very Informative.
Thanks for Sharing

Popular posts from this blog

HQL to SQL Convertor

Stepping in to the field of java API. Presenting you my first invention HQL to SQL convertor. This is a Command line version with which you can convert simple Hibernate query language(HQL) to Structured Query Language. This is my first release and not an exception for bugs and errors. If you find any errors, please feel free to inform me. Your suggestion are valuable. Usage : java -jar HQLtoSQLConvertor.jar Example: java -jar HQLtoSQLConvertor.jar "from Syndrome" HQL to SQL Convertor

Paid traffic Good or Bad

Enthusiastic bloggers and new site holders are always looking for a good traffic. Their main target is drive people to their site/blog and have a good support for their ads thereby earning something. Merchandising and popularizing a website is not an easy task. To make your website have a good reputation , you need to give a reputed website a good reputation first. In turn your reputation will be reciprocated. The sureity of people clicking your website depends upon the publicity of your website. In order to do it ,you need to ignite the fire by manually spreading all you web links over the internet world. Instead of doing that , there is an alternative available which is more popular now. Paid Traffic , what am talking about. The seed level concept of this is that , Site owners pay a concern certain amount and get a assurance of some number of visits (Say 1000 visits per $5) from unique IPs. This attract people.If they earn traffic its well and good, if not they are out just $5. The U...