private String sendCommand(Session session, RemoteCommand remoteCommand, boolean showCommand, JTextArea launcherLogWindowTextArea)
    {
        StringBuilder commandStderrBuffer = new StringBuilder();
        StringBuilder commandStdoutBuffer = new StringBuilder();

        try
        {
            Channel channel = session.openChannel("exec");
            if (showCommand)
                writeToLogWindow(launcherLogWindowTextArea, remoteCommand.getCommand() + "\n");
            ((ChannelExec) channel).setCommand(remoteCommand.getCommand());
            channel.setInputStream(null);
            //((ChannelExec) channel).setErrStream(System.err);

            // Direct stderr output of command
            InputStream fromChannelStderrStream = ((ChannelExec)channel).getErrStream();
            InputStreamReader fromChannelStderrStreamReader = new InputStreamReader(fromChannelStderrStream, "UTF-8");
            BufferedReader fromChannelStderrBufferedReader = new BufferedReader(fromChannelStderrStreamReader);

            // Direct stdout output of command
            InputStream fromChannelStdoutStream = channel.getInputStream();
            InputStreamReader fromChannelStdoutStreamReader = new InputStreamReader(fromChannelStdoutStream, "UTF-8");
            BufferedReader fromChannelStdoutBufferedReader = new BufferedReader(fromChannelStdoutStreamReader);

            channel.connect();

            byte[] tmp = new byte[1024];
            int ch;
            while (true)
            {
                if (channel.isClosed())
                {
                    remoteCommand.setExitCode(channel.getExitStatus());
                    break;
                }
                try
                {
                    Thread.sleep(1000);
                }
                catch (Exception ee)
                {
                    throw new JSchException("Cannot execute remote command: " + remoteCommand.getCommand() + " : " + ee.getMessage());
                }
            }
            channel.disconnect();

            while ((ch = fromChannelStderrBufferedReader.read()) > -1)
                commandStderrBuffer.append((char)ch);

            while ((ch = fromChannelStdoutBufferedReader.read()) > -1)
                commandStdoutBuffer.append((char)ch);

        }
        catch (Exception e)
        {
            System.out.println(e);
        }

        remoteCommand.setStderr(commandStderrBuffer.toString());
        remoteCommand.setStdout(commandStdoutBuffer.toString());

        return remoteCommand.getStdout();
    }