You can access environment variables within Ant using:

<property environment="env"/>

This provides all environment variables as Ant properties prefixed by "env.". For example, CLASSPATH would be accessible in Ant as ${env.CLASSPATH}.