--- /dev/null
+[[!meta title="Java Micro Edition"]]
+
+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][VG]
+(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][Hexist], to
+compile a simple app. Here's the source for the app with a cleaned up
+`Makefile`:
+
+* [[Makefile]]
+* [[HelloWorld.java]]
+* [[Manifest]]
+* [[!ltio icon.png]]
+
+It's a bit annoying getting a J2ME SDK set up on Linux, because the
+[Java Wireless Toolkit][WTK] 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
+creating `/etc/portage/package.mask/java_wtk` containing the line
+
+ >=virtual/jdk-1.6
+
+The Gentoo Portage tree no longer carries Java 1.5 ebuilds, so I
+installed the Java overlay
+
+ # layman -a java-onverlay
+
+I then started trying to emerge the JDK with calls to
+
+ # emerge -av virtual/jdk
+
+In order for that to succeed I had to:
+
+* Create `/etc/portage/package.keywords/java_wtk` containing
+ `dev-java/sun-jdk ~x86` to unmask the JDK.
+* Create `/etc/portage/package.use/java_wtk` containing
+ `dev-java/sun-jdk -doc` to avoid a fetch restriction on the
+ documentation.
+* Add `ACCEPT_LICENSE="dlj-1.1"` to `/etc/make.conf` to accept
+ Sun's license for Java 1.5.
+
+Take a look at the [Gentoo Java Guide][GJG] page for general
+information on running Java on Gentoo.
+
+Once I got the JDK installed, I installed the [Wireless Toolkit][WTK]
+in `~/lib/WTK2.5.2` using
+
+ $ equery files sun-jdk | grep /bin/javac
+
+to identify `/opt/sun-jdk-1.5.0.22/` as the Java SDK path.
+
+Anyhow, after getting all that setup, I learned that my
+[Verizon-provided Casio C721][C721] is running the ancient [BREW][] OS
+3.x (Chris Wright's [history of mobile games][history] 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][sig] 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][open]. I'm
+skeptical, but I suppose time will tell.
+
+[JGl]: http://today.java.net/pub/a/today/2005/02/09/j2me1.html
+[Hexist]: http://hexist.com/?p=29
+[GJG]: http://www.gentoo.org/doc/en/java.xml
+[WTK]: http://www.oracle.com/technetwork/java/download-135801.html
+[C721]: http://developer.verizon.com/jsps/devCenters/DeviceDB/Landing_Pages/BewCasioExilim.jsp
+[BREW]: http://en.wikipedia.org/wiki/Binary_Runtime_Environment_for_Wireless
+[history]: http://www.pocketgamer.biz/r/PG.Biz/A+Brief+History+of+Mobile+Games/feature.asp?c=10618
+[sig]: http://en.wikipedia.org/wiki/Binary_Runtime_Environment_for_Wireless#Development_fees
+[upgrade]: http://www.brewmp.com/showcase/verizon-wireless
+[Brew MP]: http://www.brewmp.com/
+[open]: http://news.vzw.com/news/2010/07/pr2010-06-29.html
+[WAP]: http://en.wikipedia.org/wiki/Wireless_Application_Protocol
--- /dev/null
+# Modify these appropriately for your Java installation
+
+JDK_BASE = /usr
+J2ME_BASE = $(HOME)/lib/WTK2.5.2
+
+# Modifiy these appropriately for your project
+
+NAME = HelloWorld # should also be the name of your MIDlet subclass
+SRC = HelloWorld.java
+OTHER = Manifest icon.png
+
+# Paths to standard system programs
+
+ECHO = echo
+MKDIR = mkdir
+STAT = stat
+RM = rm
+UNZIP = unzip
+
+# Paths to Java-specific programs
+
+JAVAC = $(JDK_BASE)/bin/javac
+JAR = $(JDK_BASE)/bin/jar
+EMULATOR = $(J2ME_BASE)/bin/emulator
+PREVERIFY = $(J2ME_BASE)/bin/preverify
+
+# Options passed to Java-specific programs
+
+CLASSPATH = "$(J2ME_BASE)/lib/midpapi20.jar:$(J2ME_BASE)/lib/cldcapi10.jar"
+JAVA_CFLAGS = -bootclasspath $(CLASSPATH) -target 1.3 -source 1.3 \
+ -d compiled -classpath compiled -sourcepath . -g
+PREVERIFY_CLASSPATH = $(CLASSPATH)
+
+
+all: $(NAME:%=%.jar) $(NAME:%=$.jad)
+
+run: $(NAME:%=%.jad)
+ $(EMULATOR) -Xdescriptor:$<
+
+compiled:
+ $(MKDIR) -p compiled
+
+verified:
+ $(MKDIR) -p verified
+
+compiled/%.class: %.java compiled
+ $(JAVAC) $(JAVA_CFLAGS) $<
+
+verified/%.class: compiled/%.class verified
+ $(PREVERIFY) -classpath $(PREVERIFY_CLASSPATH):compiled -d verified $(NAME)
+
+$(NAME:%=%.jar): $(OTHER) $(SRC:%.java=verified/%.class)
+ $(JAR) cfm $@ $(OTHER) -C verified $(SRC:%.java=%.class)
+
+%.jad: %.jar
+ $(UNZIP) -aa -j -p $< "META-INF/MANIFEST.MF" > $@
+ $(ECHO) "MIDlet-Jar-URL: $<" >> $@
+ $(ECHO) "MIDlet-Jar-Size: " $(shell $(STAT) -c%s $<) >> $@
+
+clean:
+ rm -rf compiled verified
+ rm -f *.jar *.jad
+
+.PHONY: clean all run