Developing Instant Messenging in J2ME

Hi, I'm trying to develop an IM using J2ME.

So i need to build an IM server, IM MIDlet client install in my mobile.
The tools i'm using is JBuilder with Mobile set and Tomcat server.

So what else do i need ?
If i have a wireless card install in my notebook, is it poosible that my mobile are able to communicate with my notebook? How?

Is urgent.
Thanks a lot.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have everything you need.  I've written a chat system using J2ME talking to a Tomcat server.  You might find that the concept of IM is quite tricky to implement since there is no concept of "push" technology in J2ME (MIDP-1.0).  This means that you are going to have to constantly poll the server to find out if any new messages are available.  There are two issues here:

1) If the client handset is using GSM to connect to the network, the user will have to be paying for the call whilst they use the system.

2) If the client handset is using GPRS to connect to the network, the user will have to pay for all the data transferred to and from the server.  This means that you need to be careful about the frequency and size of network traffic.

Your mobile can't communicate with your notebook through your wireless card.  The mobile isn't on the local area network.

If you want to do this, you might be able to use bluetooth, but you'll need a bluetooth card for your PC and a mobile that has support for the J2ME bluetooth APIs.
crasher88Author Commented:
If i can't connect mobile and notebook together, then i'll use J2ME Wireless Toolkit from Sun Microsystems. They have a simulator to help me test on it.

Is it poosible to do that? How?
Yes.  The J2ME toolkit has a built in simulator and a variety of devices (from minimum phone up to large full-colour phones).

Just make sure you have the normal Java 2 SDK installed first (1.3.1 or higher)

Then download and install the J2MEWTK (1.0.4 if you want MIDP1.0 support for current phones or 2.0 if you want MIDP2.0 support for phones that are only just being released).

You can install both and there are no conflicts.
Check Out How Miercom Evaluates Wi-Fi Security!

It's not just about Wi-Fi connectivity anymore. A wireless security breach can cost your business large amounts of time, trouble, and expense. Plus, hear first-hand from Miercom on how WatchGuard's Wi-Fi security stacks up against the competition plus a LIVE demo!

If that's all for now, could you "accept" an answer to close the question ;-)


crasher88Author Commented:
jimmack, what you told me i have already know it.

Maybe i didn't clearly ask my question.
My question is how does J2ME WTK works? How it really works? From what i can see, it just compile, build and executes.

What i want to know is, the inner of J2ME WTK. How does the simulator works?

In my developing of IM, how does the client and server communicates? How it works?

How the chat system should work...
The server must sit and wait for connections to be requested.  If you're using a read-made http server (eg. I use Tomcat), then you can create a servlet to handle connection requests.  When a request is received, the server needs to be maintaining a list of users and rooms.  If the users is posting a message, it should be written to the room to be made available to other users in that room.  If the user is requesting messages, all appropriate messages in the room should be returned to the user.
The client application needs to know the URL of the server and the format of the parameters that should be sent.  It should allow users to create and send messages and should also allow them to see the messages in a room.

How the client and server communicate...
Using standard http URLs for the communication is easier than writing your own server from scratch.

How the J2ME WTK works...
Basically just what you've said.  The wtk allows you to compiler the Java code you create, it helps to manage your projects, creates the jar file with the correct details and allows you to emulate the application.  How the emulator works is not relevant.  If you are interested in ensuring that an application works on a specific kind of phone (eg. Nokia), then download the proprietary development kit for that manufacturer/phone.
When you run a network enabled application on the emulator, it will be able to access a server on your local machine or network and on the Internet, just as you can with your web browser.
crasher88Author Commented:
Thanks alot jimmack. It really helps me in getting to know more about developing the IM application.

One more thing, Is there any interface (eg. a screen, a log file to keep any record of sessions) in the server side?

Do you mind to print screen the interface of the server side with client side and send it to me? My email address is

After that the points is yours.


I manage the sessions (rooms) in a MySQL database.

If you want to see the interface, you can look at the user guide:
Is that what you wanted?
crasher88Author Commented:
Is there any server-side interface?

Sorry for the trouble, but i need it to do my research for the IM application...

Thanks a lot..
Yes.  Sorry, when I read your last comment again, I realised that was what you actually asked for ;-)

Basically it's a JSP that contains a table.  The table is two columns wide.  One each row I have a text area that contains the complete content of the "room" and in the second column I have a list of the users that are active in the room (in another text area).

A second JSP page allows me to enter messages for users to pick up when they next contact the server.

I would give you access to the administration pages, but I'm currently discussing the sale of the application ;-)
crasher88Author Commented:
jimmack, as you have said, You maintain a room in a chat system, but in instant messaging? How to I do it? Chat is a little different from instant messaging. I pass the message straight to the other user or I store it in the database?

Ok, lets say I want to sent a message from mobile1 to mobile2. How do I do that? Can I point to the username that is unique so that it will sent to the specific user?

Can you please explain in more detail regarding the format of the parameters that should be sent?
That's the key to the problem of Instant Messaging on mobile handsets.  Originally I wanted to implement an instant messaging system and discovered that there is no practical solution (as far as I am concerned).

The handset needs to poll the server at regular intervals to see if there is a new message.  Unless you're polling every couple of seconds, it's not going to look to "instant" :-(  However, if you do poll that frequently, you'll probably find that users get annoyed with how much data they transmit/receive and also, the requests will probably overlap due to network latency.

My chat application does a check (http request) every 30 seconds (or greater) depending upon what the user selects.  By default, the user needs to check manually.

This is all because there is no way to "push" information from the server to a mobile.  It looked like this was going to be solved by MIDP-2.0, but in reality, the only push technology that is going to be generally supported is via SMS.  This is because the network operators are not willing or able to provide an IP address for every mobile connected to the network.  To be honest, I don't expect this to happen until some time after IPv6 has been adopted as a general standard (probably 4 - 5 years at least).

When my app sends an http request, it includes the user ID and any message that is being sent with the request.  The server knows which "room" the user is in and can add the new message and return any outstanding messages that the user has not yet received.

The closest you will get to an Instant Messenger is to have an idea similar to my chat, but everyone will effectively be in a single room.  Instead of the room messages being sent between users, each message will need a destination user.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
crasher88Author Commented:
Thank you jimmack.
How to contact you? If i have questions regarding this project, can i email you and ask for your opinions?

Here's your points. Thanks a lot.

Thanx ;-)

Probably best to ask further questions in this TA.  It's against EE policy to take discussions away from the community.  However, I'll probably be around and I always check this TA for new questions.

You might find other experts with different opinions or ideas that may even be more suitable for your needs at the time ;-)

Good luck with the project :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Wireless Networking

From novice to tech pro — start learning today.