In the following code below i have importted the jsch jar by clicking on Project properties and by adding the "add external jar button" also have added into the ant global path from the following link Add external jar but when i run the program i still get the "java.lang.NoClassDefFoundError: com.jcraft.jsch.JSch"
package android_jsch.com;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import com.jcraft.jsch.*;
import android.os.Bundle;
import android.widget.EditText;
public class Android_jschActivity extends Activity {
EditText ip,username,password;
@Override
public void onCreate(Bundle savedInstanceState) {
List<String> commands = new ArrayList<String>();
commands.add("touch /tmp/test1.txt");
commands.add("touch /tmp/test2.txt");
commands.add("touch /tmp/test3.txt");
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
rd);
try {
JSch jsch = new JSch();
session.connect();
Channel channel=session.openChannel("shell");//only shell
channel.setOutputStream(System.out);
PrintStream shellStream = new PrintStream(channel.getOutputStream()); // printStream for convenience
channel.connect();
for(String command: commands) {
shellStream.println(command);
shellStream.flush();
}
Thread.sleep(5000);
channel.disconnect();
session.disconnect();
} catch (Exception e) {
System.err.println("ERROR: Connecting via shell to "+ip.getText().toString());
e.printStackTrace();
}
}
private static void setUpHostKey(Session session) {
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
}
}