By default the Ant will considered the JRE as the workspace JRE version. You need to change according to your required version by following the below.
In Eclipse:
Right click on your build.xml click "Run As", click on "External Tool Configurations..." Select tab JRE.
Select the JRE you are using.
Re-run the task, it should be fine now.