Mike Slinn

Programmatic IM Generation

Published 2005-12-16.
Time to read: 1 minutes.

This page is part of the posts collection, categorized under Zamples.

I thought it would be fun to create a live code example using Zamples that would generate an IM (instant message).

The following Java code example uses Jive Software’s Smack library to send a message to a Jabber user with a Gaim client. You will need to put real values in for from, password and to before a message will be sent. BTW, if the userid and password are wrong, you’ll get an odd error message. Since the program fragment automatically compiles and runs after you click on the Try It! button, the error message will appear on the right.

Once you provide the to and from user ids and password and rerun the code fragment, a message will be sent. I tested this by sending myself a message and found that from and to were the same.

XMPPConnection connection = new XMPPConnection("jabber.org");
connection.login("from", "password");

* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.