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

Difference Between Cloudy Vision and Blurred Vision

Blurred Vision: If the Sharpness of the Image goes of, its blurred Vision. The image appears like its is not Clear and details wont be clear enough to analyze what is what. In the worst case, the Shape of the Image goes blurred, even a Cow appear as an ATM Machine Cloudy Vision: Cloudy vision means Consider a glass of water , add a drop of Milk in it. Then see how it looks. That is how you would see the world. The whole thing is clear but you would see a Mild Screen.

Moto E | MotoGP 2018 PC | Cockpit camera

Not sure if you can hear the bike noise. Keep your headphones up and enjoy the Cockpit camera