Share on Google+Share on Google+

Ant built-in Properties

In this section, you will learn how to how to find the basedir name, and file name etc.

Ant built-in Properties


This is a simple example that illustrates how to find the basedir name, file name, project name, ant version, java version, operating system name, ant home directory name, java home directory name, user home directory name and user name. Ant provides you with certain built-in properties that you may find useful during your build process. The following table shows the property name and it's description.

Ant's built-in properties:




The absolute path of the build file

The name of the project as set in the <project> element's name attribute. 


The root directory of ant


The version of this ant installation. This is not just the version number and includes information such as the compilation date.

The version of the java that ant uses


The absolute path of the project

Operating system name


Java home directory name


User directory name

User name

 Source code of build.xml:

<?xml version="1.0"?>

<project name="AntProperties" default="echo" basedir=".">

  <target name="echo">
  <echo message="The operating system is: ${}"/>  

  <!-- absolute path of the project. -->
  <echo message="The home path is: ${basedir}"/>

  <!-- absolute path of the build file. -->
  <echo message="The file name is: ${ant.file}"/>

  <!-- root directory of ant. -->
  <echo message="The Project name is: ${}"/>
  <echo message="The Ant home directory is: ${ant.home}"/>
  <echo message="The Ant version is: ${ant.version}"/> 
  <echo message="The Java version is: ${}"/>
  <!-- System properties. -->
  <echo message="The Java home directory is: ${java.home}"/>
  <echo message="The User home directory is: ${user.home}"/>
  <echo message="The User name is: ${}"/>


Run this program - the following output will be displayed:

Download Source Code




Posted on: September 6, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Ant built-in Properties   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image