You seem to open a terminal to run one command and close the terminal. This is a highly unusual workflow outside the Windows world. The usual workflow is to have a terminal open permanently, and run commands in it when needed. Or, when the command is a build command, work in an IDE and have it invoke the build process.
If you insist in creating a new terminal each time (a bad idea, because that will make messages from prior builds immediately unavailable), you can make the terminal wait in case of error by inserting a shell snippet that checks the return status, and waits for input if there is an error.
xterm -e sh -c 'ant mytarget || read line'
If the build process completes successfully, the terminal window will be closed immediately. If the build process fails, the terminal window will be closed after you press Enter.