Built In Properties
This example illustrates how to access various system properties using
Ant. Ant provides access to all system properties as if they had been defined
using a <property>
task. Here is a list of the properties with descriptions.
Property |
Description |
basedir |
the absolute path of the project's basedir (as set with the basedir attribute of <project>). |
ant.file |
the absolute path of the buildfile. |
ant.version |
the version of Ant |
ant.project.name |
the name of the project that is currently executing; it is set in the name attribute of <project>. |
ant.java.version |
the JVM version Ant detected; currently it can hold the values "1.2", "1.3", "1.4" and "1.5". |
ant.home |
home directory of Ant |
java.version |
JRE version |
java.vendor |
JRE vendor |
java.vendor.url |
Java vendor URL |
java.home |
Java installation directory |
java.vm.specification.version 0 |
JVM specification version |
java.vm.specification.vendor |
JVM specification vendor 1 |
java.vm.specification.name |
JVM specification name |
java.vm.version 2 |
JVM implementation version |
java.vm.vendor |
JVM implementation vendor 3 |
java.vm.name |
JVM implementation name |
java.specification.version 4 |
JRE specification version |
java.specification.vendor |
JRE specification vendor 5 |
java.specification.name |
JRE specification name |
java.class.version 6 |
Java class format version number |
java.class.path |
Java class path 7 |
java.ext.dirs |
Path of extension directory or directories |
os.name 8 |
Operating system name |
os.arch |
Operating system architecture 9 |
os.version |
Operating system version |
file.separator 0 |
File separator ("/" on UNIX) |
path.separator |
Path separator (":" on UNIX) 1 |
line.separator |
Line separator ("\n" on UNIX) |
user.name 2 |
User's account name |
user.home |
User's home directory 3 |
user.dir |
User's current working directory |
The source code of build.xml file
<project name="Built-In-Properties" default="echo" basedir="."> |
Run this code – the following output will be displayed.
5