'Overwrite Java_Home from Ant Build.xml file

How can we set Java_Home from a build.xml file using ant build. Currently my project gets build with java 1.8. But recently reporting tools have been migrated to java 11. i need to set Java_home to a different version of java after compile happens and just before running the reporting ant script from the build.xml file :

build.xml...

//compile goes here with default java_home
//reporting goes here.. need to set Java_home to 11 here
<ant antfile="ant/test.xml" inheritall="false" inheritrefs="false"/>  


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source