Search code examples
javaopenfiresmack

Cannot create FileTransferManager object


I am trying to implement file transfer in my project but cannot create FileTransferManager object it says:

FileTransferManager (org.jivesoftware.smack.Connection) in FileTransferManager cannot be applied to (org.jivesoftware.smack.tcp.XMPPTCPConnection)

Here is my code:

 FileTransferManager manager = new FileTransferManager(connection);
            // Where connection is an object of XMPPTCPConnection

Using Smack 4.2.0 and Openfire server


Solution

  • If we are talking about the class org.jivesoftware.smackx.filetransfer.FileTransferManager it has no public constructor however it has a static factory method:

    public static synchronized FileTransferManager getInstanceFor(XMPPConnection connection)
    

    so i would try the following:

    FileTransferManager manager = FileTransferManager.getInstanceFor(connection);
    

    Are you sure that you imported a right class? Because you shouldn't be able to call its constructor at all.