Reputation: 594
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.
Upvotes: 2
Views: 6064
Reputation: 475
Convert jsch jar file to DEX format and include the classes.dex along with the jar in the build path.
Upvotes: 1
Reputation: 7526
Create a folder with name libs and import your jar file in there.
for more info visit this link
Upvotes: 2