The propose of this tutorial is to retrieve the current logged username, computer name and operation system name in Ant, we echo these values in below example. Computer name and OS name are actually Ant build-in properties.

This is an example to get values in Ant.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Here is how you can access How to get username,
computer name and OS Name in ANT.
<project basedir="." default="echosysteminfos" 
name="Echo username, computer name and OS Name">

  <target name="echosysteminfos">
    <property environment="my_env" />
      Username is ${my_env.COMPUTERNAME}
      Computer name is ${}
      OS Name is ${}

This was the output after executing this ant script.

Buildfile: build.xmlechosysteminfos:
[echo]        Username is asjava-PC
[echo]        Computer name is asjava
[echo]        OS Name is Windows NT (unknown)
Total time: 0 seconds