May 31

Last month I ported a couple of my J2ME/LWUIT apps on Android. I used the LWUIT port from Thorsten [1]. I downloaded the source code from LWUIT incubator SVN [2], but I spent a lot of time in merging the LWUIT original classes with the Thorsten's classes needed to port to Andoid and then I spent a lot of time again to produce a .jar usable with Android SDK.

In this post I want to share the Eclipse project that I created to compile and jar the Thorsten's LWUIT Android port and I want to show how to write a simple HelloWorld LWUIT-Android project.

Requirements:

1) Eclipse Helios or later
2) Android SDK
3) LWUITPortAndroid eclipse projectnz

You can download LWUITPortAndroid from here:LWUITPortAndroid.zip
You may want to update the source code to the latest version of Thorsten's port. If so check out the latest Thorsten's port from the SVN url above and overwrite the classe in my project.
If you don't want to recompile the Android port, you can download only my .jar: LWUITAndroidPort.jar.
Then, I prepared a simple hello world eclipse project to show how to move from and J2ME/LWUIT project to an Android project: HelloWorldLWUITAndroid.zip
Mainly your Android activity must subclass LWUITActivity class and in the method getFullApplicationPath you should return the full name of your midlet class:

public String getFullApplicationPath(){
        return "com.cryptware.HelloWorldMidlet";
        // (make sure that obfuscators don't mess with the class name and path.)
    }

And that's all. You can use your LWUIT midlet on an Android device with a few lines of code.

References:

[1] Thorsten's LWUIT Android port: http://www.pader-sync.com/lwuit-for-blackberry-and-android.html
[2] LWUIT incubator SVN: https://svn.java.net/svn/lwuit-incubator~svn

 


Tags: | |

Comments

ho

Posted on Wednesday, 24 August 2011 06:06

I tried to recompile the LWUIPortAndroid (Just recompile it, no updated code). I open the project in eclipse, fix the JRE and android.jar path, but it still get many warnings in the project. Most of them are something like "Vector is a raw type. References to a generic type Vector <E> should be parameterized". Do you know what is wrong? My JRE version is 7 and jdk compliance level is set to 1.6.

Thanks

Android tablet review

Posted on Tuesday, 29 November 2011 21:16

I got really great results with LWUIT midlet!

Thanks buddy.

raja

Posted on Thursday, 22 December 2011 11:19

Hai I am a beginner for android.. i m implementing your project it's work's great.. I have implementing another lwuit project source into android project....  But i have an run-time error for implementing image and res file... pls tell me how to i implement the Theme res file and images.. send me a sample code.... or related links... sorry for my bad english. i hope u should understand what i am saying. Pls help me.

Carlos

Posted on Tuesday, 10 January 2012 00:05

Hi, great article and job. Now I'm in trouble with my j2me project, I use RecordStore (javax.microedition.rms) and HttpConnection (javax.microedition.io.HttpConnection), but javax doesn't exists 'couse is j2me and NOT android project...I saw that you rewrite Midlet class for android...so I will have to rewrite for httpconnection and RecordStore too for android? I would appreciate any advice. Thanks!