I have an OpenFire server and am trying to build a Smack Client to connect to it. Initially, I am just trying to use the Smack API with the code below (from an answer here):
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Presence;
public class Main {
public static void main(String[] args)
{
ConnectionConfiguration config = new ConnectionConfiguration(
"talk.google.com", 5222, "google.com");
XMPPConnection connection = new XMPPConnection(config);
Presence presence;
String status;
try {
connection.connect();
connection.login("mail_id@gmail.com", "password");
status = "DND";
presence = new Presence(Presence.Type.available, status, 24,
Presence.Mode.available);
while (true) {
status = set(status);
presence.setStatus(status);
connection.sendPacket(presence);
Thread.sleep(1000);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
connection.disconnect();
}
}
private static String set(String input) {
return input.substring(1) + input.charAt(0);
}
}
However, I keep getting the error below
Exception in thread "main" java.lang.NoClassDefFoundError: org/kxml2/io/KXmlParser at org.jivesoftware.smack.XMPPConnection.(XMPPConnection.java:110) at org.jivesoftware.smack.ConnectionConfiguration.(ConnectionConfiguration.java:57) at Main.main(Main.java:8) Caused by: java.lang.ClassNotFoundException: org.kxml2.io.KXmlParser at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 3 more
Any help will be appreciated