Java Mobile Edition Development Tools
Work In Progress
This is a guide to installing a complete development, testing, and packaging environment for Java MIDlets - applications for mobile devices - on Ubuntu Jaunty. It is also an attempt to confirm and define a completely open-source tool-set. In other words, it attempts to avoid any dependency on Sun Java Wireless Toolkit.
Free Open Source Overview
The FOSS (Free Open-Source Software) tools installed are:
- IcedTea build of OpenJDK 6. Licence GPL
- Eclipse IDE for Java Developers 3.4.x aka Ganymede. Licence EPL
- Eclipse Mobile Tools for Java (MTJ) Licence EPL
- Antenna for Wireless Java. Licence LGPL (preprocessor EPL)
- MicroEmulator (pure Java implementation of Java ME in Java SE). Licence LGPL
- ProGuard (class file shrinker, optimizer, obfuscator, and preverifier). Licence GPL with limited linking exception
The usual non-FOSS option is to use Sun's JWT (and most tool stacks expect it) instead of MicroEmulator and ProGuard.
Sun JWT is only available as 32-bit binary classes so to use it on a 64-bit host environment a 32-bit Java development kit would be needed alongside the default 64-bit JDK, and would only be used to launch the JWT tools.
The mix of licences for the various tools is mind-boggling, confusing, and enough to put you off. This is my current understanding of the situation but it may not be entirely accurate so do your own research - don't rely on me.
The Sun JWT preverifier has been released under the GPL as part of the PhoneMe project. MTJ can be configured with the location of the Sun JWT as part of the Antenna configuration but it will then use all the Sun JWT tools - free and non-free.
Recently however ProGuard has added a pre-verifier. MTJ has been modified sufficiently to be able to call an external pre-verifier using a defined command-line. That allows ProGuard to be used for pre-verification as well as for obfuscation. Antenna will use ProGuard (or RetroGuard) for obfuscation. MTJ expects ProGuard as the defined obfuscator.
Installation
OpenJDK
Ensure OpenJDK is installed
sudo apt-get install openjdk-6-jdk
... and the default JVM
sudo update-alternatives --config java
Eclipse
Create a location to install Eclipse
sudo mkdir /usr/lib/eclipse-3.4
Download the latest Eclipse IDE for Java Developers from eclipse.org (~163MB).
Extract the file to the new location, removing the leading "eclipse/" from the file paths in the archive
sudo tar -xzf eclipse-jee-ganymede-SR2-linux-gtk-x86_64.tar.gz -C /usr/lib/eclipse-3.4 --strip-components 1
Startup Script
Create an updated and customised version of the Ubuntu Eclipse 3.2.x package start-up shell script. I've attached it for easy download. Rename it if necessary to work alongside the Ubuntu Eclipse package:
sudo wget --directory-prefix=/usr/bin http://tjworld.net/raw-attachment/wiki/Linux/Ubuntu/JavaMobileEditionDevelopmentTools/eclipse sudo chmod a+x /usr/bin/eclipse
Extension Locations
With the Eclipse start-up script in place it can be used to easily install Eclipse extensions outside of the main Eclipse installation directory. This is very useful since otherwise Eclipse can get over-loaded with unnecessary extensions when using some perspectives.
The first thing to do is ensure developers have permissions to install to the installation location. I generally will use /usr/local/lib/eclipse-$VERSION/ as the base path for extensions.
sudo mkdir -p /usr/local/lib/eclipse-3.4 sudo chown root:staff /usr/local/lib/eclipse-3.4
Add the user account(s) that will share the extensions to the staff group
sudo usermod -aG staff ${USER}
Note: The group membership won't become active until the next time the user logs on.
Mobile Toolkit for Java
Start eclipse with a custom location for the extension
/usr/bin/eclipse -ver 3.4 -configuration /usr/local/lib/eclipse-3.4/MTJ
The directory will be created by Eclipse. When Eclipse starts set the Workspace location then use Help > Software Updates... > Available Software > Add Site = http://download.eclipse.org/dsdp/mtj/updates/0.9/stable (get this URL from the MTJ Update sites page.
Give Eclipse a few seconds to read and parse the update site. If successful the dialog will be updated with the additional options. Select the MTJ.
Press the Install... button then the Finish button and wait whilst the extension is downloaded and installed. Don't restart Eclipse at this point - press the No button and then exit Eclipse completely.
Check the extension was installed into the correct location
ls -l /usr/local/lib/eclipse-3.4/MTJ/eclipse/plugins/
Create a link to the extension in the main Eclipse installation:
sudo mkdir /usr/lib/eclipse-3.4/links echo "path=/usr/local/lib/eclipse-3.4/MTJ" | sudo tee /usr/lib/eclipse-3.4/links/MTJ.link
Antenna
Download from the antenna web site and copy the jar file into a suitable location (which will be set in the Eclipse MTJ extension later). I put it in /usr/local/lib/
MicroEmulator
Download from the web-site and extract the archive into /usr/local/lib/
tar -xzf microemulator-2.0.3.tar.gz -C /usr/local/lib
ProGuard
Download from the web site and extract the archive into /usr/local/lib/
tar -xzf proguard4.3.tar.gz -C /usr/local/lib
Configuration
Eclipse
Add some head-room to the user's default Java VM settings
echo -e "VMARGS=\"-Xms128m -Xmx512m -XX:PermSize=64M -XX:MaxPermSize=128M\"" >> ~/.eclipse/eclipserc
Mobile Toolkit for Java
Start Eclipse with the default installation location (this assumes the MTJ extension has been installed and linked as detailed previously)
/usr/bin/eclipse -ver 3.4
Select Window > Preferences > Java ME and set the Antenna location (/usr/local/lib/antenna-bin-1.1.0-beta.jar)
Expand Java ME in the navigator pane and choose Device Management and press the Import... button.
Enter the location of MicroEmulator (/usr/local/lib/microemulator-2.0.3)
Expand Packaging in the navigator pane and choose Obfuscation. Set the ProGuard Root Directory (/usr/local/lib/proguard4.3)
Choose Preverification in the navigator pane and set the command to run the default preverifier (java -jar /usr/local/lib/proguard4.3/lib/proguard.jar @/usr/local/lib/proguard4.3/midlet.pro)
Press the OK button to apply the changes and close the Preferences dialog.
ProGuard
Create a pre-verifier profile midlet.pro that can be used by Eclipse MTJ in the ProGuard base directory (here it is /usr/local/lib/proguard-4.3/). Notice that it relies upon external libraries provided by MicroEmulator so ensure the paths match the installed location since they are based on package versions.
-injars in.jar -outjars out.jar -libraryjars /usr/local/lib/microemulator-2.0.3/lib/midpapi20.jar -libraryjars /usr/local/lib/microemulator-2.0.3/lib/cldcapi11.jar -dontshrink -dontoptimize -dontobfuscate -microedition
References
Creating deployable MIDlets with free software - François Kooman
Developing for Mobiles with Java on Ubuntu - Liam Green-Hughes
MTJ Getting Started
Reasons to switch to the Eclipse Mobile Tools for Java
p2: how I install plugins in extension locations... - Michael Scharf
Attachments
-
eclipse
(6.0 KB) -
added by tj 17 months ago.
/usr/bin/eclipse shell script to start eclipse
-
midlet.pro
(231 bytes) -
added by tj 17 months ago.
midlet.pro - the ProGuard? pre-verifier configuration
-
Screenshot -Software Updates and Add-ons .png
(16.7 KB) -
added by tj 17 months ago.
Screenshot - Add MTJ extension
-
Screenshot-Preferences-JavaME.png
(17.4 KB) -
added by tj 17 months ago.
Screenshot - Java ME Antenna settings
-
Screenshot-Import Devices.png
(22.0 KB) -
added by tj 17 months ago.
Screenshot - Java ME Import Devices
-
Screenshot-Preferences-Obfuscation.png
(21.0 KB) -
added by tj 17 months ago.
Screenshot - Java ME Obfuscation
-
Screenshot-Preferences-Preverification.png
(31.3 KB) -
added by tj 17 months ago.
Screenshot - Java ME Preverification





