code: public ChannelExec getExecChannel(String command) throws SftpException {
      ChannelExec channelExec;
      try {
        channelExec = (ChannelExec) this.session.openChannel("exec");
        channelExec.setCommand(command);
        channelExec.connect();
        return channelExec;
      } catch (JSchException e) {
        throw new SftpException(0, "Cannot open a channel to SFTP server", e);
      }
    }
docs: Create a new sftp channel to execute commands.
  
  @param command to execute on the remote machine
  @return a new execution channel
  @throws SftpException if a channel could not be opened