Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 36 of 36

Thread: How to Write a simple XMPP (Jabber) client using the Smack API

  1. #26
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: How to Write a simple XMPP (Jabber) client using the Smack API

    Quote Originally Posted by richie1985 View Post
    Hello,

    how can i use single sign on to authenticate the client?


    thanks!
    Hello.

    I am unsure what you mean? Can you please start a new thread regarding this issue.

    Thanks.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  2. #27
    Junior Member
    Join Date
    Apr 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to Write a simple XMPP (Jabber) client using the Smack API

    Quote Originally Posted by JavaPF View Post
    Hello.

    I am unsure what you mean? Can you please start a new thread regarding this issue.

    Thanks.
    Yes i do it:

    http://www.javaprogrammingforums.com...-sign-sso.html

  3. #28
    Junior Member
    Join Date
    May 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to Write a simple XMPP (Jabber) client using the Smack API

    hello everbody
    i installed openfire server on my machine , and i programmed a software with java , an instant messanger interfaces ,( client interfaces and administrator interfaces ) i added this code of smack , but the problem is , i dont know how i am gonna use xmpp protocol to add it to my application so i can communicated the client with the administrator !! can anyone please tell me what i gotta do else to make my project work as an instant messanger !! and thank you again !!

  4. #29
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: How to Write a simple XMPP (Jabber) client using the Smack API

    Quote Originally Posted by MTW View Post
    hello everbody
    i installed openfire server on my machine , and i programmed a software with java , an instant messanger interfaces ,( client interfaces and administrator interfaces ) i added this code of smack , but the problem is , i dont know how i am gonna use xmpp protocol to add it to my application so i can communicated the client with the administrator !! can anyone please tell me what i gotta do else to make my project work as an instant messanger !! and thank you again !!
    Please start a new thread regarding this issue. The best forum to post in is here - Java Networking

    Have you tried getting the example code to work by itself?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  5. #30
    Junior Member
    Join Date
    Jun 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to Write a simple XMPP (Jabber) client using the Smack API

    hello to everybody

    why when i run your program the connection is refused


    i did only copy and past!!!!!!

    why????

  6. #31
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: How to Write a simple XMPP (Jabber) client using the Smack API

    Do you have a server? You can't just run the code I posted without configuring it.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  7. #32
    Junior Member
    Join Date
    Jun 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to Write a simple XMPP (Jabber) client using the Smack API

    hello
    i have a problem to presence notification. this is the code:
    public void displayBuddyList()
        {
    Roster roster = connection.getRoster();
    Collection<RosterEntry> entries = roster.getEntries();
    System.out.println("\n\n" + entries.size() + " buddy(ies):");
    Presence presence;
    for(RosterEntry r:entries)
    {
    System.out.println(r.getUser());
    presence = roster.getPresence(r.getUser());
    System.out.println(presence);
    }
        }

    but my contacts are always unavailable Could you help me? pleaseeeeeeeeeee

  8. #33
    Junior Member
    Join Date
    Jun 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: How to Write a simple XMPP (Jabber) client using the Smack API

    somebody help me

  9. #34
    Junior Member
    Join Date
    Jul 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to Write a simple XMPP (Jabber) client using the Smack API

    hello,
    i used this code for jabber client

    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 chat 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("jabber.org");

    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<RosterEntry> 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
    chat c = new chat();
    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("hassan786@jabber.org", "bcsf08m018");

    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);
    }
    }

    Problem is that

    i have made account on jabber.org now if i run the this java programme so if i put my own username and password as well as on console when programme asked that to which user you wanted to connect if i put my own username again than this programme send message and also show on console the recieve message .But if on console i put some other jabber username to which i send message and this user is also online (means run this application on another laptop) but he never recieve the message on his console.

    Also explain what parameters i put for jabber account there(new ConnectionConfiguration("im.server.here",5222, "Work")

  10. #35
    Junior Member
    Join Date
    May 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to Write a simple XMPP (Jabber) client using the Smack API

    reply to " swaqpoli " post

    presence = roster.getPresence(r.getUser());
    after above line try with presense.getStatus();
    the same problem i have faced when i am running it on local
    but when i run it on our site it runs perfectly. once u try with uploding application into your real website

  11. #36
    Junior Member
    Join Date
    Aug 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to Write a simple XMPP (Jabber) client using the Smack API

    Quote Originally Posted by padmashree View Post
    I couldn't login to local ejabberd server using smack API. I could connect Miranda IM to ejabberd local server but whenever I try to do the same using smack, it throws this exception -
    Exception in thread "main" SASL authentication failed using mechanism DIGEST-MD5:
    at org.jivesoftware.smack.SASLAuthentication.authenti cate(SASLAuthentication.java:325)

    Following is the used java class. It is able to connect but not able to login. I also tried setting XMPPConnection.DEBUG_ENABLED = true and config.setSASLAuthenticationEnabled(false), but in vain.

    public class  ConnectionToLocalServer {
        private static String username =  "admin@localhost"; 
        private static String password =  "genespring123"; 
        ConnectionConfiguration connConfig;
        XMPPConnection connection;
     
        public ConnectionToLocalServer() throws  XMPPException {  
        	ConnectionConfiguration config = new ConnectionConfiguration("localhost",5222);        
            connection = new XMPPConnection(config);
            connection.connect();
            System.out.println("CONNECTED..");
            connection.login(username, password);
            System.out.println("LOGED IN..");
        }
     
        ...
       }
    }
    pamashree? do you already have an answer on this?

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Writing in a file using Java
    By JavaPF in forum File Input/Output Tutorials
    Replies: 4
    Last Post: December 17th, 2011, 04:33 PM
  2. [SOLVED] web client
    By 5723 in forum File I/O & Other I/O Streams
    Replies: 8
    Last Post: June 10th, 2009, 04:44 PM
  3. [SOLVED] Java exception "result already defined"
    By rptech in forum Object Oriented Programming
    Replies: 3
    Last Post: May 20th, 2009, 05:48 AM
  4. Problem while programming a simple game of Car moving on a road
    By rojroj in forum Java Theory & Questions
    Replies: 3
    Last Post: April 2nd, 2009, 10:24 AM
  5. Java program to write game
    By GrosslyMisinformed in forum Paid Java Projects
    Replies: 3
    Last Post: January 27th, 2009, 03:33 PM

Tags for this Thread