powered by Jive Software

Something simple to start "xmpp" with "java"

Hi, I’m spanish, and I have questions about Threads in openfire.

When I make a java des connection with a smack xmpp server Seller, I have a question and do not fall.

How do I make a thread that never ends? while (true) in the run?

What I’m trying to do is “leave a user always on” until the disconnect unwilling

I’ve seen chats say an advanced level using listeners, and have a simple run but that the user is always connected.

As I am confused on the topic threads ha threads that are used in messages (to synchronize messages obviously), the exchange of packets, that is where there is a run and an async task!

I hope you understand the problem presented before me.

If the user does not need any thread, and only messages telling me.

(Sry my language)


You really should be more clear about your problem.

  • What is a “des connection”?

  • You talk about a “Smack XMPP server seller”, which doesn’t make any sense to me.

  • You mix together Java Threads (concurrency) and Message Threads (XMPP), which are completely different things.

If your problem is, that Java Threads (and therefore your main()) are dying, maybe this is helpful, but it has nothing to do with XMPP, only with Java basics:

public static void main(final String[] args) {

// Create the main application thread, that will run forever and will keep the program alive.

Executors.newFixedThreadPool(1, new ThreadFactory() {


public Thread newThread(Runnable r) {

return new Thread(r, “Main Application Thread”);


}).execute(new Runnable() {


public void run() {

// connect, login, receive messages…




Sry my language is to bad, google tradcutor unconjugated…

the phrase “When I make a java des connection” error conjugated = “When I make a connection java”

I talk about xmpp because I need a conection to server xmpp, and I do not know if exist one method “session users” that not use threads.

your answer is the best, works correctly, I never execute a run how you, is awesome.

say that I new in xmpp, I’m a little disoriented, but thx about communiti I can continue.

Also say now programming in java oo, because I need works in a code correctly for after send this code in java Android

Good Job @CSH, I hope you help me more !!

Yes, the fixedThreadPool will keep the thread alive and therefore the JVM, so that your application won’t terminate.

I’m glad I could help, but please visit an english course.