build.xml is something like makefile in C/C++ world. It's used to tell the
ant to do some certain tasks, compiling, deploying, etc.
Go to this link
http://java.sun.com/j2ee/1.4/download.html#tutorial and download the tutorial. The tutorial contains all the source codes (
java code, build.xml, etc). That tutorial was created using NetBeans
IDE, that's why you can see the nbproject directory inside.
If you use IDE, such as NetBeans or Eclipse, the IDE will generate the build.xml when you create a new project.