2

i'm trying to ssh connect from my android phone to a ssh server.

My import line:

    import com.jcraft.jsch.*;

and here the rest

    try{
        JSch jsch = new JSch();

        //create SSH connection
        String host = "192.168.158.20";
        String user = "jan";
        String password = "mypassword";

        Session session = jsch.getSession(user, host, 22);
        session.setPassword(password);
        session.connect();
        System.out.println("done");
      }
      catch(Exception e){
        System.out.println(e);
     }

I'm using Jsch (java ssh implementation) for that. I've downloaded the jsch-0.1.48.jar from the website and added it to my eclipse android project's build path via "right click project -> libraries -> Add Jars"

I can now see the jsch-0.1.48.jar file inside my Referenced Libraries so that seems to be ok.

When i start the debug i get a Could not find class 'com.jcraft.jsch.JSch' error from LogCat at the line 1.

Eclipse shows me no warnings or syntax errors.

ThinkTeamwork
  • 544
  • 5
  • 19

2 Answers2

2

Create a folder with name libs and import your jar file in there.

for more info visit this link

Community
  • 1
  • 1
Akram
  • 7,548
  • 8
  • 45
  • 72
  • i tried that and followed the link without success, although it seemed to have solved the problem for somebody with very similar problem – ThinkTeamwork Jul 25 '12 at 20:09
1

Convert jsch jar file to DEX format and include the classes.dex along with the jar in the build path.

cutebug
  • 475
  • 4
  • 10
  • What do you mean by " include the classes.dex along with the jar in the build path" do we replace? – solti Mar 05 '14 at 22:07