How to use smack API 4.1.1 with open fire with given Java Class? It give so much errors

import java.util.*;

import java.io.*;

import org.jivesoftware.smack.Chat;

import org.jivesoftware.smack.ConnectionConfiguration;

import org.jivesoftware.smack.MessageListener;

import org.jivesoftware.smack.Roster;

import org.jivesoftware.smack.RosterEntry;

import org.jivesoftware.smack.XMPPConnection;

import org.jivesoftware.smack.XMPPException;

import org.jivesoftware.smack.packet.Message;

public class JabberSmackAPI implements MessageListener{

XMPPConnection connection;

public void login(String userName, String password) throws XMPPException

{

ConnectionConfiguration config = new ConnectionConfiguration(“im.server.here”,5222, “Work”);

connection = new XMPPConnection(config);

connection.connect();

connection.login(userName, password);

}

public void sendMessage(String message, String to) throws XMPPException

{

Chat chat = connection.getChatManager().createChat(to, this);

chat.sendMessage(message);

}

public void displayBuddyList()

{

Roster roster = connection.getRoster();

Collection entries = roster.getEntries();

System.out.println("\n\n" + entries.size() + " buddy(ies):");

for(RosterEntry r:entries)

{

System.out.println(r.getUser());

}

}

public void disconnect()

{

connection.disconnect();

}

public void processMessage(Chat chat, Message message)

{

if(message.getType() == Message.Type.chat)

System.out.println(chat.getParticipant() + " says: " + message.getBody());

}

public static void main(String args[]) throws XMPPException, IOException

{

// declare variables

JabberSmackAPI c = new JabberSmackAPI();

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

String msg;

// turn on the enhanced debugger

XMPPConnection.DEBUG_ENABLED = true;

// Enter your login information here

c.login("[B]username[/B]", “[B]password[/B]”);

c.displayBuddyList();

System.out.println("-----");

System.out.println(“Who do you want to talk to? - Type contacts full email address:”);

String talkTo = br.readLine();

System.out.println("-----");

System.out.println("All messages will be sent to " + talkTo);

System.out.println(“Enter your message in the console:”);

System.out.println("-----\n");

while( !(msg=br.readLine()).equals(“bye”))

{

c.sendMessage(msg, talkTo);

}

c.disconnect();

System.exit(0);

}

}

This is the solution that I have got…

Do not forget to add below jars:

jxmpp-core-0.4.1

jxmpp-util-cache-0.5.0-alpha2

minidns-0.1.3

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.Collection;

import org.jivesoftware.smack.AbstractXMPPConnection;

import org.jivesoftware.smack.ConnectionConfiguration;

import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;

import org.jivesoftware.smack.MessageListener;

import org.jivesoftware.smack.SASLAuthentication;

import org.jivesoftware.smack.SmackException;

import org.jivesoftware.smack.SmackException.NotConnectedException;

import org.jivesoftware.smack.XMPPException;

import org.jivesoftware.smack.chat.Chat;

import org.jivesoftware.smack.chat.ChatManager;

import org.jivesoftware.smack.packet.Message;

import org.jivesoftware.smack.roster.Roster;

import org.jivesoftware.smack.roster.RosterEntry;

import org.jivesoftware.smack.sasl.SASLMechanism;

import org.jivesoftware.smack.sasl.javax.SASLDigestMD5Mechanism;

import org.jivesoftware.smack.tcp.XMPPTCPConnection;

import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;

public class JabberSmackAPI implements MessageListener{

AbstractXMPPConnection connection;

public void login(String userName, String password) throws XMPPException

{

XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration.builder();

config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);

//this is server name in Open fire

config.setServiceName(“servername.com”);

config.setUsernameAndPassword(“user”,“user”);

//this is host name in Open fire

config.setHost(“localhost”);

config.setPort(5222);

config.setDebuggerEnabled(false);

SASLMechanism mechanism = new SASLDigestMD5Mechanism();

SASLAuthentication.registerSASLMechanism(mechanism);

SASLAuthentication.blacklistSASLMechanism(“SCRAM-SHA-1”);

SASLAuthentication.unBlacklistSASLMechanism(“DIGEST-MD5”);

config.setSecurityMode(SecurityMode.disabled);

connection = new XMPPTCPConnection(config.build());

try {

connection.connect();

connection.login(userName, password);

} catch (SmackException | IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public void sendMessage(String message, String to) throws XMPPException

{

Chat chat = ChatManager.getInstanceFor(connection).createChat(to);

try {

chat.sendMessage(message);

} catch (NotConnectedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public void displayBuddyList()

{

Roster roster = Roster.getInstanceFor(connection);

Collection entries = roster.getEntries();

System.out.println("\n\n" + entries.size() + " buddy(ies):");

for(RosterEntry r:entries)

{

System.out.println(r.getUser());

}

}

public void disconnect()

{

connection.disconnect();

}

public void processMessage(Chat chat, Message message)

{

if(message.getType() == Message.Type.chat)

System.out.println(chat.getParticipant() + " says: " + message.getBody());

}

public static void main(String args[]) throws XMPPException, IOException

{

// declare variables

JabberSmackAPI c = new JabberSmackAPI();

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

String msg;

// Enter your login information here

c.login(“user”, “user”);

c.displayBuddyList();

System.out.println("-----");

System.out.println(“Who do you want to talk to? - Type contacts full email address:”);

String talkTo = br.readLine();

System.out.println("-----");

System.out.println("All messages will be sent to " + talkTo);

System.out.println(“Enter your message in the console:”);

System.out.println("-----\n");

while( !(msg=br.readLine()).equals(“bye”))

{

c.sendMessage(msg, talkTo);

}

c.disconnect();

System.exit(0);

}

@Override

public void processMessage(Message arg0) {

// TODO Auto-generated method stub

}

}