×
Namespaces

Variants
Actions
(Difference between revisions)

Getting started with Java ME

From Nokia Developer Wiki
Jump to: navigation, search
pillar (Talk | contribs)
(What tools to use)
hartti (Talk | contribs)
m
Line 1: Line 1:
[[Category:Java]][[Category:How To]]
+
[[Category:Java]][[Category:How To]][[Category:IDE/SDK]]
  
 
'''(This page is very much work in progress, please add more information, and screenshots link to other relevant pages and edit it to give more complete view of this)'''
 
'''(This page is very much work in progress, please add more information, and screenshots link to other relevant pages and edit it to give more complete view of this)'''

Revision as of 11:19, 25 September 2007


(This page is very much work in progress, please add more information, and screenshots link to other relevant pages and edit it to give more complete view of this)

Basically getting your first Java ME application (MIDlet) running on a real device, requires a number of steps. This Wiki page tries to guide through the process. As this is targeted to first time MIDlet developers, some things are simplified, and more detailed information can be found elsewhere

Contents

Analyze the situation

Java ME is a limited subset of the standard Java (Java SE) available on the desktop computers. Additionally there are some mobile phone related APIs available. There are a number of limitations you need to keep in mind

  • MIDlets run in a sandbox because of security reasons (there are confirmations when using certain functionalities, like networking or sending SMS messages)
  • There is no JNI (Java Native Interface) so you cannot extend the capabilities of Java ME environment on the phone
  • There is no Swing or AWT classes, MIDlets use their own (simplistic) UI classes
  • The capabilities of the Java ME environment vary widely, meaning that the phones have different set of optional APIs implemented (examples include access to files, access to phonebook, video/audio recording, 3D graphics, etc.)

So first of all, before starting anything else, think if Java ME is the right choice for you or should you try to use Flash Lite for your application (runs both on Series 40 and S60 phones), or should you start using Symbian C++ programming (those apps work on S60 phones).

If Java ME seems to be the way to go, you can find a lot of good information in this Wiki or in the FN Java Discussion Forums. There is also documentation available on Forum Nokia web site, as well at Sun Web site and IBM DeveloperWorks Web site.

Overview of the development process

First note, that you have to code, compile and package the MIDlet on a computer. You cannot create a MIDlet on the phone itself (yet).

You can use whatever text editor or IDE (Integrated Development Environment) you like to write the MIDlet code. Then compile the code with the javac compiler which is comes with the Java SE SDK (JDK). Even though you do not need to worry about it right now, your code is also preverified at this stage.

Before being able to install the MIDlet on a real device, you still need to package the MIDlet classes to JAR (Java Archive) and JAD (Java Application Descriptor) files. The JAR file contains all the code needed to run the application. The JAD file is a text file containg descriptive information about the MIDlet (size, needed APIs, MIDlet name, Vendor name, optional signing information), which the phone (and user) can use to decide whether or not to download the MIDlet at all. You need only to install the JAR file on the phone to be able to run the MIDlet, however it is recommended to use both of the files to install the App (you will be thankful for this tip in the future :-)

At this stage you can test the MIDlet on your development workstation using the phone emulator (and of course make some changes to the app and compile/package it again). When you are satisfied to the MIDlet you can transfer the JAR and JAD file to the phone, install it and test the application on the phone (it is always advised to test the MIDlet on a real device also)

What tools to use

You will be better off using a Windows-based computer for development, as many of the phone SDKs do not work properly on Linux.

JDK

  • (insert description here)

Full-blown IDEs

  • Netbeans
  • Eclipse ME [1]

Please note: As of right now, in order to maintain full compatibility with Nokia SDKs, you need to have Eclipse 3.1x and therefore will not be able to use newer Eclipse ME than 1.2.3. Newer versions will work to some extent, but not reliably.

  • etc

Phone SDK

Coding and compiling your first MIDlet

(Will contain short code for HelloWorld MIDlet)

Running your MIDlet in the emulator and on real device

(Will contain packaged HelloWorld MIDlet for testing purposes)

Typical pitfalls

Compiling the Java ME code with wrong Java compliance option

The correct compliance is 1.3 or 1.4. Compiling with 5.0 or 6.0 compliance makes it impossible to install the MIDlet.

Compiling and packaging the MIDlet for incorrect CLDC or MIDP version

This is especially true when using Sun Wireless Toolkit, which by default builds the MIDlet for MIDP 2.1. However, most of the current phones have only MIDP 2.0 available. (Note, that you can install on a phone a MIDlet with lower CLDC/MIDP version than what the phone supports, but you cannot install a MIDlet with higher CLDC/MIDP version on the phone. Check the supported CLDC and MIDP versions on FN device specification pages.)

530 page views in the last 30 days.
×