gradle: command not found while executing on remote machine
<p>I want to execute gradle commands on remote machine which has mac OS. I have written Java program and using JSch library. I'm able to execute other commands like pwd, ls, etc. But when I execute any gradle command it says</p>

<pre><code>Connected
bash: gradle: command not found
exit-status: 127
DONE
BUILD SUCCESSFUL (total time: 8 seconds)
</code></pre>

<p>I have already set GRADLE_HOME path in profile and I'm able to execute command from terminal but not from remote program. </p>

<p>Following is my Java program</p>

<pre><code>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package commandexecuter;

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import java.io.InputStream;
import java.util.Properties;

/**
 *
 * @author dgulhane
 */
public class CommandExecuter {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        String host = "abc.xyz.com";
        String username = "Admin";
        String password = "123456";
        String command = "gradle -v";


        try {
            java.util.Properties config = new Properties();
            config.put("StrictHostKeyChecking", "no");
            JSch jSch = new JSch();

            Session session = jSch.getSession(username, host, 22);
            session.setPassword(password);
            session.setConfig(config);
            session.connect();
            System.out.println("Connected");

             Channel channel=session.openChannel("exec");
            ((ChannelExec)channel).setCommand(command);
            channel.setInputStream(null);
            ((ChannelExec)channel).setErrStream(System.err);

            InputStream in=channel.getInputStream();
            channel.connect();
            byte[] tmp=new byte[1024];
            while(true){
              while(in.available()&gt;0){
                int i=in.read(tmp, 0, 1024);
                if(i&lt;0)break;
                System.out.print(new String(tmp, 0, i));
              }
              if(channel.isClosed()){
                System.out.println("exit-status: "+channel.getExitStatus());
                break;
              }
              try{Thread.sleep(1000);}catch(Exception ee){}
            }
            channel.disconnect();
            session.disconnect();
            System.out.println("DONE");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
</code></pre>

<p>I want to know how can I execute gradle commands remotely</p>