Wednesday, February 3, 2010

HOW-TO: Eclipse + Java Platform, Micro Edition (Java ME/J2ME) (02/04/2009) for Windows

HOW-TO: Eclipse + Java Platform, Micro Edition (Java ME/J2ME) 02/04/2010 for Windows

1. Download the requirements:


Java Platform (JDK) : http://java.sun.com/javase/downloads/widget/jdk6.jsp (Jave SE only not Java EE or anything)

Eclipse Pulsar (Pulsar for Mobile Java Developers) http://www.eclipse.org/downloads/packages/pulsar-mobile-java-developers/galileosr1 (eclipse-pulsar-galileo-SR1-win32.zip)

Sun Java Wireless Toolkit for CLDC http://java.sun.com/products/sjwtoolkit/download.html (don't download Java ME SDK 3.0. , just the sun_java_wireless_toolkit-x_x_x-windows.exe)

2. Install java sdk 6.0 and sun java wireless toolkit to their default directory.

3. Configure eclipse:


Unzip eclipse. Run eclipse.exe.

Go to Window->Preferences->Java ME->Device Management.

Then import the wireless toolkit. (Default location is C:/WTK22 or something else, probably C:/WTKxx)

4. Test some example apps:

Create a midlet project. Select File->New->Midlet Project.

After creating a new project, import existing apps into it:

Go to File->Import->General->File System. Then browse for the examples

(I would recommend C:\WTK22\apps\NetworkDemo and C:\WTK22\apps\WMADemo).

To compile, select Project->Build all. To run, right click on the main src file then select

Run as-> Emulated Java MIDlet.

(eg. To run NetworkDemo , go to src/socket then right click on SocketMIDlet.java then select Run as-> Emulated Java MIDlet)

(eg2. To run WMADemo, go to src/example/sms then right click on SMSSend.java then select Run as-> Emulated Java MIDlet)


5. other tips:


Use Navigator window instead of Package explorer (Select Window->Show View->Navigator)

Don't use build automatically. Uncheck it from Project->Build Automatically.

To have a clean build. Clean it first before building (Project->Clean, then Project->Build All)

6. Tips on WMA addon, etc.
If you create an instance of a MIDlet, the emulator will automatically add a cellphone number into it. The Default is: 1st instance is +5550000, 2nd instance is +5550001 and so on.

Study how it connects two cellphones for sms messaging. Instead of using ip add+socket, it uses the phonenumber+socket. Good thing is it mimics sockets and tcp connection or something like that.

In the WMA sms example, there are 3 src files. SMSReceive.java has the GUI for receiving data and some other stuff. It implements a thread for receiving SMS msg. It also uses SMSSender.java for sending.

SMSSend.java has the GUI for sending. It uses SMSSender.java for sending.

SMSSender.java is a thread for sending SMS. Threads are used to avoid I/O error stuff. So 1 app uses 2 threads, 1 for receiving and 1 for sending.

No comments: