Could not find or load main class org.gradle.launcher.GradleMain

I am trying to build build.xml file. Simply the build file is called the gradle build and then run the tests. However I am getting error regarding gradle. This is the first time for me using gradle. The error is

Could not find or load main class org.gradle.launcher.GradleMain

I already set the PATH and GRADLE_HOME in variable environment . I am using version 3.3. This this part of the code of build.xml where I am calling the gradle

<target name="compile" description="Compile the  source code.">
<exec executable="/bin/bash">
    <arg value="gradle"/>
    <arg value="build"/>
</exec>
</target>

Am I missing something?

Any suggestion that could solve this problem. This question had asked before but there is only one answer and it did not solve the problem.