0

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 ?

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
LaPalme
  • 339
  • 5
  • 16

2 Answers2

3

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!

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Ok, nice ! Thank you, I have 0.1.31 so that's it ! I thought I had downloaded the last one... Have a nice day – LaPalme Aug 23 '17 at 08:33
-1

https://epaul.github.io/jsch-documentation/simple.javadoc/com/jcraft/jsch/JSch.html#setConfig-java.lang.String-java.lang.String-

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.

zenki1201
  • 1
  • 1
  • Thank you. Yes I get the difference, but I don't understand why the code works in this example : https://stackoverflow.com/questions/15108923/file-transfer-using-java-jsch-sftp I don't see any difference between this code and mine... I would like to do the same – LaPalme Aug 22 '17 at 09:40
  • 1
    @zenki1201 That's `JSch.setConfig`, while the question is about `Session.setConfig`. – Martin Prikryl Aug 22 '17 at 16:04