This question has already been asked here: "The method setConfig(Properties) in the type Session is not applicable for the arguments (String, String)" more than a year ago but it doesn't have any answer and I have the same problem just now.
Unfortunately I didn't find anything more on Google.
import com.jcraft.jsch.*;
import java.io.*;
import java.util.Properties
JSch jsch = new JSch();
String user = "myUserId";
String host = "myHost";
Session session = jsch.getSession(user, host, 22);
session.setConfig("StrictHostKeyChecking", "no");
My code is as simple as that and I have the following message:
The method setConfig(Properties) in the type Session is not applicable for the arguments (String, String).
So I tried another way to do the same thing, but it's not normal that it doesn't work. Does anyone know where is the problem ?
There are three overloads of the Session.setConfig
in latest JSch 0.1.55:
public void setConfig(java.util.Properties newconf)
public void setConfig(java.util.Hashtable newconf)
public void setConfig(String key, String value)
If you do not have the third overload, you must be using some very old version of JSch. The overload was introduced in JSch 0.1.34 in 2007!
as said in documentation it's a static method so it should be the 'Session' where Session is the class not and object session. i hope you understand the difference.
来源:https://stackoverflow.com/questions/45812585/setconfigproperties-in-the-type-session-is-not-applicable-for-the-arguments-s