Josh Josh - 6 months ago 28
Java Question

How to Communicating between a J2ME Midlet and PC?

How do I make a J2ME Midlet to communicate with a java program or some application on the pc through the cable connected?


Incredible_Honk is almost right. The key is to use the (standard) system property "microedition.commports". This provides a comma delimited list of the com ports which are available to your application. To open a connection use CommConnection as follows:

CommConnection con = (CommConnection)"com:<commport name>");

Usually this will provide access to a USB serial connection, possibly also infrared if available. Iterate through each one to see which one corresponds to the connection you're looking for.

On Windows at least, you will need to install the correct drivers for your handset first. This will then allow you to open a serial connection and communicate with the application.