Search code examples
javaintellij-ideaxmppopenfiresmack

I'm having trouble creating XMPP client using smack 4.2 Openfire


I want to create a simple XMPP client that connects to my Openfire server. I got the following problem when I'm running the code.

code:

public void setConnection() {

    try {

        XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();
        config.setUsernameAndPassword(userName,password);
        config.setResource("temp");
        config.setXmppDomain("undercrroft");

        AbstractXMPPConnection connection = new XMPPTCPConnection(config.build());
        connection.connect();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (SmackException e) {
        e.printStackTrace();
    } catch (XMPPException e) {
        e.printStackTrace();
    }

Error:

Information:java: Errors occurred while compiling module 'Messenger'
Information:javac 1.8.0_121 was used to compile java sources
Information:16/4/17 1:52 AM - Compilation completed with 2 errors and 0 warnings in 871ms
/home/paradox/Desktop/Project/Messenger/src/ConnectServer.java
Error:(28, 19) java: cannot access org.jxmpp.stringprep.XmppStringprepException
                class file for org.jxmpp.stringprep.XmppStringprepException not found
Error:(29, 19) java: cannot access org.jxmpp.jid.DomainBareJid
                class file for org.jxmpp.jid.DomainBareJid not found

These are my imports:

import org.jivesoftware.smack.AbstractXMPPConnection;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;

Thanks.


Solution

  • Update the Library..!

    Those two libraries are defined in the newer library.