Sunday, February 1, 2009

Getting the tools for Java, Bluetooth, MIDlet and Serial port

Before we dive into the source code, I thought it would be a good idea to explain where to get the tools needed for developing mobile applications. These are the tools:
  • Java Development Kit
  • Eclipse
  • Sun Java Wireless Toolkit for CLDC
  • EclipseME
  • Bluecove (java bluetooth library)
  • Java Runtime Environment for your mobile phone
  • RXTX (serial port library)
The best part is, is that these tools are supposed to be working on Windows, Linux and Mac OS! (I haven't tested that, though!)

Java Development Kit (JDK)
The application is coded in Java, and so are MIDlets. You can get a JDK from Sun or openJDK. Mac OS already has a JDK installed by default. At the time of writing, I'm using openJDK 6 on Ubuntu.

You should have heard about Eclipse before, if you haven't, try a quick Google search to find out more about it. In short: it's an open source IDE, we'll be doing all of the coding with this program. Go to their download page and download Eclipse IDE for Java EE Developers (~160 MB). Always download the latest version, but FYI I used Eclipse 3.4 a.k.a. Ganymede.

Sun Java Wireless Toolkit for CLDC
We are going to use this toolkit to run our MIDlets in an emulated device, get it here. Update: there is no official support for Mac OS, but this guy seems to have got it working.

EclipseME is an Eclipse plugin to help develop J2ME MIDlets. On their site there is a very detailed installation guide. In short:
Make sure you downloaded and installed Eclipse and the Sun Java Wireless Toolkit for CLDC first. Use the update manager in Eclipse to install EclipseME (it's all covered in the installation guide).

BlueCove is a Java library for Bluetooth (JSR-82 implementation), without such a library we are unable to use Bluetooth in our applications. Here's the download link. You need only one or two files depending on your operating system. Windows/Mac users only need bluecove-x.x.x.jar, Linux users also need the bluecove-gpl-x.x.x.jar file. (Latest stable version at time of writing: 2.1.0.)

Java Runtime Environment (JRE) for your mobile phone
A lot of devices come with a JRE nowadays, however, not all those devices support the Bluetooth specification, also known as JSR-82. That means that even if your device has Bluetooth, you would not be able to use it with your Java application. Check your device manual or see this (incomplete afaik) list of devices which support JSR-82 natively, if your device has a JSR-82 implementation, you're in luck.
If your device does not have a JRE, you have to install one yourself if possible. If it's not possible, you will have to look for another device to test it on. Note that you do not need to have a JRE on your device to begin writing and testing the application, but I recommend you install it, without it, you won't be able to fully test your application (I'll disclose why in another post). phoneME is a very promising JRE for Windows Mobile. Precompiled binaries are available here, make sure you download the phoneME Advanced Dual Stack version, the other versions are not capable of supporting Bluetooth and MIDlets. You need to copy a few files from Bluecove into the phoneME installation to enable the Bluetooth library on your Windows Mobile device, see this description.
If you're interested in more information about phoneME, you can also visit the official phoneME project website. As an alternative to phoneME, you can also download Mysaifu JVM (currently version 0.4.1). This JRE cannot run MIDlets, though, but it can run Bluetooth enabled applications in combination with Bluecove. I do not have any experience with other mobile device operating systems, so if you do not have Windows Mobile and do not have a JSR-82 capable device, you'll have to do a little research of your own.

RXTX (serial port library)
We are going to address the serial port directly with Java. (Yes, you can send data to the serial port from command line, but who'd use such a crude programming method? :) ) We need the RXTX library for this, get it here. If you're on Ubuntu, you can install the package 'librxtx-java', the library will be available at /usr/share/java/RXTXcomm.jar.

When you downloaded and installed all the software, you're ready to start your first project (e.g. Bluetooth application). I will cover this another time.


  1. As the author of EclipseME, I would like to suggest that instead of using the last release of EclipseME you look to the Eclipse Mobile Tools for Java (MTJ) instead. MTJ started with the last release of EclipseME and has added many new features and fixed a lot of bugs.

  2. Thanks for the suggestion csetera, I'll certainly check it out.

  3. Can you please elaborate on what rxtx will do and what are we supposed to do once we download it.

  4. Hi silk,

    RXTX is a serial port communication library. Serial ports are also implemented over BlueTooth, e.g. if you'd want to connect to your BlueTooth GPS dongle, you will probably have to make a serial connection to the device. Once you're connected, you can talk to the device as if it were a local device using serial communication.

    I dug up an example for you on how to use rxtx on a local port:

  5. Your work is very good and I appreciate you and hopping for some more informative posts. Thank you for sharing great information to us.
    Cheap Budget beaches in India
    Daughters of 7 Top Bollywood Villains
    south indian actress name list with photo

  6. OSCARS 2018 - 90th Academy Awards 2018 Nominations, Date, Host, Presenters, Winners, Predictions. OSCARS 2018 Winners, OSCAR Nominations 2018, OSCAR 2018 Predictions, OSCAR Winners 2018, Jimmy Kimmel Host OSCAR Awards 2018, Best Picture Nominees, Winner, Best Actor, Actress, Director.

    how to watch oscar 2018

  7. Really appreciated the information and please keep sharing, I would like to share some information regarding online training.Maxmunus Solutions is providing the best quality of this JBOSS Technology And this online training will be very convenient for the learner.And the training will be online and very convenient for the learner.

    For Joining online training batches please feel free to call or email us.
    Email :
    Contact No.-+91-9066638196/91-9738075708