Apache Ant Hello World
To create a simple hello world project, we are using Eclipse IDE and the project require the below steps.
- Create a Java Project
- Create a Java File
- Create an XML File
- Create a Folder
- Run as Ant Build
Java Project
Create a project by selecting Java project from the File menu and provide it’s name.
Java File
Create a Java class by providing it’s name Hello, see the below example.
XML File
Create an XML File by providing it’s name build. Build is a default name but we can set other name also.
Create a Folder
Create a folder to organize compiled Java class files. The folder can be anything, here we have created a test folder.
Project Structure
After creating all the above files, our project should look like the below.
In this project, Java and XML file contains the below code to display Hello World message.
// Hello.Java
// build.xml
Run Project
To run the project, right click in the build.xml file and select Run as → Ant Build. After running that, it shows the output in a specific format, see the below.
Output: