I must connect with a linux host via ssh.
I found the library "Ganymed", it seemed to work but I saw that some commands do not give me the desired result.
For example, I tried to run the following commands
"cd .."
the output of the first command is the same as the third.
This is the basic code for the ssh connection
Java Code:
String hostname = "";
String username = "joe";
String password = "joespass";

/* Create a connection instance */
Connection conn = new Connection(hostname);

/* Now connect */

boolean isAuthenticated = conn.authenticateWithPassword(username, password);

if (isAuthenticated == false)
   throw new IOException("Authentication failed.");

/* Create a session */
Session sess = conn.openSession();

sess.execCommand("uname -a && date && uptime && who");

System.out.println("Here is some information about the remote host:");

InputStream stdout = new StreamGobbler(sess.getStdout());
BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
while (true)
   String line = br.readLine();
   if (line == null)

/* Show exit status, if available (otherwise "null") */
System.out.println("ExitCode: " + sess.getExitStatus());

/* Close this session */

/* Close the connection */

catch (IOException e)

In jar file of the library I found other examples, that creates a shell using swing.
In this example the comand go well.
Someone knows how to solve my problem?
You know other library that can I use?
Before "Ganymed" I tried "jsch" library and I have the same problem.
Thank you in advance for you answer