Many cell phones and similar devices run a constrained version of the Java Virtual Machine (JVM) called the Sun Java Wireless Toolkit CLDC , Java 2 Micro Edition, or something similar (Sun/Oracle seem to like changing package names). If you want to write a MIDlet that runs on your phone, take a look at Vikram Goyal's detailed tutorial (note: Windows-based commands, but they translate easily into Linux equivalents).
After installing a J2ME SDK (see below) I worked through the examples
in Vikram's tutorial and those in a post by Hexist, to
compile a simple app. Here's the source for the app with a cleaned up
It's a bit annoying getting a J2ME SDK set up on Linux, because the
Java Wireless Toolkit requires the old and buggy Java 1.5. On
my Gentoo box, I had to mask version of the JDK greater than 1.5 by
/etc/portage/package.mask/java_wtk containing the line
The Gentoo Portage tree no longer carries Java 1.5 ebuilds, so I installed the Java overlay
# layman -a java-overlay
I then started trying to emerge the JDK with calls to
# emerge -av virtual/jdk
In order for that to succeed I had to:
dev-java/sun-jdk ~x86to unmask the JDK.
dev-java/sun-jdk -docto avoid a fetch restriction on the documentation.
/etc/make.confto accept Sun's license for Java 1.5.
Take a look at the Gentoo Java Guide page for general information on running Java on Gentoo.
Once I got the JDK installed, I installed the Wireless Toolkit
$ equery files sun-jdk | grep /bin/javac
/opt/sun-jdk-126.96.36.199/ as the Java SDK path.
Anyhow, after getting all that setup, I learned that my Verizon-provided Casio C721 is running the ancient BREW OS 3.x (Chris Wright's history of mobile games says that BREW went commercial in 2002, but doesn't list specific version release dates). To top that off, they charge $400 for a developer signature needed to install apps on your own phone.
There is an outside chance that they are getting their act together though, with vague press releases about upgrading to Brew MP and lowering the barrier to entry for app-delivery. I'm skeptical, but I suppose time will tell.