Java ME

From wiki.gpii
Jump to: navigation, search

About Java ME implementation

Firstly, with Java ME implementation we mean all those OS platforms for mobile devices that are able to run JME-based applications on them. Under the goals and terms of the Cloud4all project, this implementation aims to bring the GPII to all those mobile devices with less resources but are based-up/or support JME applications, and they are also known as Simple Phones.

Since these Simple Phones aren't able to run the GPII framework by their own and every Simple Phone runs its own OSs with different system's APIs, we decided to create an application which could be run on every JME-compatible Simple Phone. And this application should (at least) cover the needs and functionalities that were detected during an early activity of the Cloud4all project. Some of these functionalities are described in the following table:

Funtionality Description
Login (text) User can use the GPII by putting his/her userToken in a text box
Login (QR) User can use the GPII by reading his/her userToken from a QR code
Login (NFC) User can use the GPII by reading his/her userToken from an NFC tag
Contact Manager User can add, remove, edit and call to any contact from his/her personal contact list
Messenger Manager User can send an SMS/MMS message
Media Player User can play a sound or video
Proximity search A user can search for accessible hotel PoIs (Points of Interests) in a specific area.

The returned hotel should be presented on a map and should be met his/her preferences.

Communication/Chat tool User can talk with other users with a Skype-like or other existing communication applications.
Screen Reader User can use a TTS service to interact with the device
Application Launcher Top-level application from where to manage all these components

After this first iteration round, we've achieved these following functionalities:

  • Login (text)
  • Contact Manager
  • Media player
  • Application Launcher

And for the second iteration, the team working on this implementation will try to enhance the application to cover almost all of the desired functionalities.

The Java ME application

The app will let you connect to the Flow Manager and do some operations like changing font size, theme or sound volume. Also you should be able to launch the Internet browser, make photographs, get GPS coordinates, etc.

You can get and test a precompiled build or get the source code and build it yourself.


Building the app is an easy process, where the most time-consuming task is downloading the tools from Internet.

Source code

You can get the code from or just:

 git clone

Required tools

For building the JME application you'll need:

  • Eclipse or NetBeans IDE
I've set up my enviroment with Eclipse for Mobile Developers, version Juno Service Release 2. You can grab it from: Other versions should work OK too.
  • Codename One plugin for Eclipse or NetBeans
Add this update site to Eclipse:

For further details on installation, you can read Codename One "get started guide" here:

Set up the environment, build and run on emulator

It seems there is no automagic option in CodenameOne for importing projects into Eclipse, so we must do it manually:

  • Open Eclipse and go to File / New / Other... / CodenameOne / CodenameOne Project
  • Creation wizard must appear. Set exactly the names and options as described:
Project name: cloud4AllThemes
Main class name: MyThemes
Theme and Template: default ones
  • Click "Finish" button. A default "Hello world" project must have been created.
  • At this point, if you press "Run" button, the emulator should be launched showing "Hello word" application. Alternatively, you can run it going to the "Package Explorer" and right-clicking over "Simulator_cloud4AllThemes.launch" file / Run As / Simulator_cloud4AllThemes.
  • In order to import the application, remove "Hello world" src/ directory and copy the one from the source code previosly downloaded instead. Do the same operation with "".
If you have problems importing the application, check out the "Running the Codename One Demos In Eclipse" epigraph in
  • Refresh project (press F5). Now you should be able to run the cloud4AllThemes application.

Emulator limitations

The emulator is a Java program that runs in your computer. In order to use some multimedia capabilities in the emulator, you should run it with Java 7. In my Linux box, I had to get the Oracle Java 7 version, since the emulator didn't recognice the OpenJDK Java 7 one.

Testing on devices

cloud4AllThemes application running on an old Nokia N81 device, using Spanish language

In order to build the application for real devices, you'll have to use the Codename One build server. This is a cloud service and you'll need to create a free account if you want to use it.

Once you have logged in your account, right-click on the project title and go to "CodenameOne / Send RIM build" for BlackBerry devices or "CodenameOne / Send J2ME build" for other Java ME devices. The server will build them for you, and then provide a link to download it.

However, we include two precompiled packages for standard Java ME and BlackBerry devices.

Precompiled builds

Note: At the moment, the precompiled packages are only uploaded in my personal fork (dertalai branch):

 git clone
 git checkout dertalai
  • BlackBerry build: cloud4AllThemes/precompiled/blackberry/
Media files deleted in this build for reducing file size.
Codename One compiles for Blackberry OS 5.0. It should be compatible with newer versions too.
Codename One compiles with its own certificate. An alert will show before installation, asking if you trust the certificate.
  • Generic JME build: cloud4AllThemes/precompiled/jme/
media files deleted in this build.

Supported / tested devices

Note: A frequent issue about real devices is the leak of memory due to integrated media files (.wav, .mp4, etc.) in the application. You can search for them into src/ directory of the project and delete them before building.

  • Nokia N81 (geneeric JME build) and Nokia 701
Just send the file via bluetooth and open it to install. Or maybe you can copy it via USB connection or an SD card, then open it.
  • BlackBerry Curve 8520 (BlackBerry build) and BlackBerry Z10
I've installed and run some other apps made with Codename One, but I was unable tu run MyThemes on it. At the moment I'm getting the following error message: "Error starting MyThemes5: Module 'MyThemes5' attempts to access a secure API."