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...

How to get rid of phishing sites

Some one is trying to play with me. Am not the one whom they are looking for. Recently i received a mail with a name PAYPAL . The mail is apparent that , this is some kind of fraud. No special knowledge is required to identify a phishing site. Just look around the mail for suspicious information. Some critical clues The Contents of the mail is as Follows 1. In Sender address - the domain name is other than paypal(i.e it is not support@paypal.com ) 2. The mail is found in SPAM folder 3. The Mail greets me as Dear PP member . But the fact, Paypal greets every member with their Name . 4. The Web Link. This is quite tricky. It almost looks like paypal official website. But if you can look a bit deeper, you can see some other names are also appended. Many people might not notice everything and blindly click the link and provide their secret information and lose themselves. Mostly busy people are trapped as they fail to notice due to lack of time. I put forward my own experience here in this...