Its my first post

Im doing a java Netbeans program to connect into SSH server, this SSH server is used to connecto to others machines using telnet or SSH.
Im using Jframe and 2 TexArea one input and one output
The program woriking fine I can send a recive data from/to server. the server is Unix and I can send unix command.

To send data to server:
try {
DataOutputStream dataOut = new DataOutputStream(ch.getOutputStream());
// ventana.mensajeRecibido(sMensaje);
} catch (IOException e) {
JOptionPane.showMessageDialog(ventana, "No se pudo enviar el mensaje");

To recive data:
InputStream stream = ch.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));

String line = reader.readLine();
// while(!line.endsWith(endLineStr)) {
while (line != null) {
// System.out.println(line);
line = reader.readLine();

es > telnet
This will create a new /home/emigbur/.telnetrc
Press RETURN to continue, CTRL-C to abort
Execute "xauth add $XAU" in target environment
If the path isn't set up you maybe need to write eg. /usr/X/bin/xauth
This may also be executed by a login script...

If $XAU isn't transfered to the target environment
you'll need to manually add the cookie by typing or pasting
this: xauth add MIT-MAGIC-COOKIE-1 10e6c597b2b3874de80a42ddc9f842b9

Connected to
Escape character is '^]'.


login: ^@


Connection closed by foreign host.
Is like the server and client are not sync.
I tried to add xForwarding whitout success
Cans some one know how to fix it.

Out off topic.
Im my out text area I had the outscroll but I have to sroll manually how I can set it to auto scroll and see the lasted message

thanks in advance