I am trying to get a remote connection to server to execute some commands. I am new to this so started googling. After some search, I gave a try:
I am using sshj0.2.3.jar.
And here is how I implemented it:
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
final SSHClient ssh = new SSHClient();
ssh.loadKnownHosts();
ssh.connect("serverName");
try{
ssh.authPublickey("myUserId");
final Session session = ssh.startSession();
try{
final Command cmd = session.exec("net send myMachineName Hello!!!");
System.out.println(cmd.getOutputAsString());
System.out.println("\n Exit Status: "+cmd.getExitStatus());
}finally{
session.close();
}
}finally{
ssh.disconnect();
}
}
}
But I get the folowing exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
at net.schmizz.sshj.DefaultConfig.<init>(DefaultConfig.java:92)
at net.schmizz.sshj.SSHClient.<init>(SSHClient.java:133)
at SSHTEST.main(SSHTEST.java:24)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory at java.net.URLClassLoader.findClass(URLClassLoader.java:419) at java.lang.ClassLoader.loadClass(ClassLoader.java:643) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:345) at java.lang.ClassLoader.loadClass(ClassLoader.java:609) .....
Do I need extra jars,How many extra jars do i need. AM I implementing correctly?. please help.
Thanks in advance.