To read the variable from java, use System.getenv().get("ANT_HOME")
. Read more about it here.
As for where to set it, I prefer using ~/.bashrc, unless you're going to run your program from other users, or with sudo
. Then you should use /etc/environment