ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH

Hi

I am running a build in jenkins and we use Gradle. Recently suddenly one day our builds started to fail with the below error. So for some reason gradle driven build is unable to find the JAVA PATH. Can some provide help as to why suddenly it is not able to find JAVA?

ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.