Java ME source code examples for cell phone robot
Java ME Source code examples
Recently we reviewed our code of www.RoboHobby.com project and we
decided to public some code examples.
On this page you can see soma simple code samples of Java ME part of the project, which
may be useful for robot builders.
There are a lot of J2ME code examples in the Internet.
But this set of code examples are specific.
The code is for those, who want to use Java (mainly Java ME)
as a base language for creating robot's brain.
They show our step-by-step progress, starting from most simple examples to more complecated.
In fact you can think of this code as am education material.
The code was written by me or by my son in education process.
In 2004-2006 I was trying to teach my son Java.
Now I think it is time to share my experience and public some code on my site.
How there will be the day when it will be possible to public all the code of the project.
Sorry, but it is not ready yet to be published. I should prepare it for the public.
By the way, I am looking for a way to public source code on the web in good readable form.
I mean there must be the way how to convert Java source code
to good formated HTML with color highlights.
I mean comments should be gray, code should be black, key words should be green,
variables should be blue, for example, etc.
If you know any Java tool something like JavaDoc, XDoclet, TagLet, etc,
which can solve this problem (transfprmation from Java source code to HTML with text of Java code),
please, send me message.
All example projects were reconstructed from their original form (JDK 1.4.2, Netbeans 4.0, etc.)
to modern form.
Now all the examples are re-written for Netbeans 6.5 with Java 1.6.
All of them are ready to be used and tested with Siemens S75 cell phone.(CLDC-1.1, MIDP-2.0).
I am sorry for so short description of these project.
Hope I will find the time for detailed description with illustrations (print screens, etc.).
Run Java ME Code Examples
String-to-Calendar and Calendar-to-String conversion. (Usefull for Java ME).
First simple example - Java ME Timer
Java ME Robot Timer Task
Java ME Robot Timer Task Midlet
Java ME Timer JavaDoc
Timer is one of the key feature of Java ME based hobby robot. Theoretically it is possible
to run threads on cell phones, but practically these threads are very specific.
You can not do a lot of things, which you can do with Java SE.
Practically we should not run a lot of parallel threads in Java ME.
In real life it is better to use timers then work with threads.
To use this simple project you should download zip file from our server.
Unzip it to your PC, for example to
Then open Netbeans 6.5 and point it to the directory (File/Open Project).
Then you can compile it, build, generate JavaDoc, etc., using Netbeans.
Note: After the compilation (Clean&Build) you can see resulting jar and jad files in the
This folder (Timer) you can put to your 'Application' directory on your phone.
And run it there.
Also this project you can run right in the Netbeans IDE.
It works there.
Next project is Java ME Disc
Java ME Disc Utils
Java ME Disc Utils Midlet
Java ME Disc JavaDoc
This project illustrates how to write information as a file to file system of your telephone.
It is also important for robot project. Using this feature you can save o n local disc
(in constant memory or on removable card (SD, RS MMC, etc.) some information, like images,
sensor information, some other info, got on the road, like navigation info, etc.
Using this project you can view roots of your phone's file system.
Client-Server Project 'Java ME Http'
Java ME Http Utils
Java ME Http Utils Midlet
Java ME Http JavaDoc
Robot should be able to communicate with web server via GPRS+Internet.
This simple project read string from web server. In our case it is just server Date/Time in Java format.
Java ME Image ShootingJava ME Image Shooting
Java ME ImageShooting JavaDoc
Robot should be able to see, where it is going. It should be able to do snap shots,
using embedded camera.
Java ME Saving Image on Local DiscJava ME Saving Image on Local Disc. Midlet.
Java ME Saving Image on Local Disc. Utils.
Java ME ImageDisc JavaDoc
Robot should be able to save images in the cell phone file system.
Java ME Image TimerJava ME Saving Image on Local Disc by timer. Midlet.
Java ME Saving Image on Local Disc by timer. Utils.
Java ME ImageTimer JavaDoc
This project is able to do snap-shots periodically, using timer and save images on the local disc.
Java ME 'Disc Command' example
Java ME 'Disc Command'. Midlet.
Java ME DiscCommand JavaDoc
Using this project you can test simple way of sending commands to cell phone.
If you install this application, run it and then put file 'cmd.txt'
with letter 'C' (means 'capture') to directory
then the application will read it, do one snap-shot and then save it on the
local disc of cell phone.
That means you can put the cell phone with running program in one place (in one room for example)
then connect to cell phone, using standard PC Bluetooth software (from another room) and put 'cmd.txt' file in local file system
of the phone and do one shoot.
Then you can get image from /MMCard/Pictures/DiscData/ directory remotelly.
Sorry for so short description. I will add more details soon.