mkogg.py: Fix 'self.get_mp4_metadata(self, source)'
[blog.git] / posts / Java_ME.mdwn
1 [[!meta title="Java Micro Edition"]]
2
3 Many cell phones and similar devices run a constrained version of the
4 Java Virtual Machine (JVM) called the Sun Java Wireless Toolkit CLDC ,
5 Java 2 Micro Edition, or something similar (Sun/Oracle seem to like
6 changing package names).  If you want to write a MIDlet that runs on
7 your phone, take a look at Vikram Goyal's detailed [tutorial][VG]
8 (note: Windows-based commands, but they translate easily into Linux
9 equivalents).
10
11 After installing a J2ME SDK (see below) I worked through the examples
12 in Vikram's tutorial and those in a [post by Hexist][Hexist], to
13 compile a simple app.  Here's the source for the app with a cleaned up
14 `Makefile`:
15
16 * [[Makefile]]
17 * [[HelloWorld.java]]
18 * [[Manifest]]
19 * [[!ltio icon.png]]
20
21 It's a bit annoying getting a J2ME SDK set up on Linux, because the
22 [Java Wireless Toolkit][WTK] requires the old and buggy Java 1.5.  On
23 my Gentoo box, I had to mask version of the JDK greater than 1.5 by
24 creating `/etc/portage/package.mask/java_wtk` containing the line
25     
26                 >=virtual/jdk-1.6
27
28 The Gentoo Portage tree no longer carries Java 1.5 ebuilds, so I
29 installed the Java overlay
30
31     # layman -a java-overlay
32
33 I then started trying to emerge the JDK with calls to
34
35     # emerge -av virtual/jdk
36
37 In order for that to succeed I had to:
38
39 * Create `/etc/portage/package.keywords/java_wtk` containing
40   `dev-java/sun-jdk ~x86` to unmask the JDK.
41 * Create `/etc/portage/package.use/java_wtk` containing
42         `dev-java/sun-jdk -doc` to avoid a fetch restriction on the
43         documentation.
44 * Add `ACCEPT_LICENSE="dlj-1.1"` to `/etc/make.conf` to accept
45         Sun's license for Java 1.5.
46
47 Take a look at the [Gentoo Java Guide][GJG] page for general
48 information on running Java on Gentoo.
49
50 Once I got the JDK installed, I installed the [Wireless Toolkit][WTK]
51 in `~/lib/WTK2.5.2` using
52
53     $ equery files sun-jdk | grep /bin/javac
54
55 to identify `/opt/sun-jdk-1.5.0.22/` as the Java SDK path.
56
57 Anyhow, after getting all that setup, I learned that my
58 [Verizon-provided Casio C721][C721] is running the ancient [BREW][] OS
59 3.x (Chris Wright's [history of mobile games][history] says that BREW
60 went commercial in 2002, but doesn't list specific version release
61 dates).  To top that off, they charge [$400 for a developer
62 signature][sig] needed to install apps on *your own phone*.
63
64 There is an outside chance that they are getting their act together
65 though, with vague press releases about [upgrading][] to [Brew MP][]
66 and [lowering the barrier to entry for app-delivery][open].  I'm
67 skeptical, but I suppose time will tell.
68
69 [VG]: http://today.java.net/pub/a/today/2005/02/09/j2me1.html
70 [Hexist]: http://hexist.com/?p=29
71 [GJG]: http://www.gentoo.org/doc/en/java.xml
72 [WTK]: http://www.oracle.com/technetwork/java/download-135801.html
73 [C721]: http://developer.verizon.com/jsps/devCenters/DeviceDB/Landing_Pages/BewCasioExilim.jsp
74 [BREW]: http://en.wikipedia.org/wiki/Binary_Runtime_Environment_for_Wireless
75 [history]: http://www.pocketgamer.biz/r/PG.Biz/A+Brief+History+of+Mobile+Games/feature.asp?c=10618
76 [sig]: http://en.wikipedia.org/wiki/Binary_Runtime_Environment_for_Wireless#Development_fees
77 [upgrading]: http://www.brewmp.com/showcase/verizon-wireless
78 [Brew MP]: http://www.brewmp.com/
79 [open]: http://news.vzw.com/news/2010/07/pr2010-06-29.html
80 [WAP]: http://en.wikipedia.org/wiki/Wireless_Application_Protocol
81
82 [[!tag tags/java]]
83 [[!tag tags/linux]]
84 [[!tag tags/programming]]