You can set a system property in your Java program, and Ant will capture it, but you must make sure you don't fork your <java>
task.
Another possibility is to output the value, and capture that value in the outputproperty
parameter of the <java>
task. You already stated you can't use the return value.