×
Namespaces

Variants
Actions
(Difference between revisions)

Getting started with Java ME

From Nokia Developer Wiki
Jump to: navigation, search
balagopalks (Talk | contribs)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix metadata)
(37 intermediate revisions by 18 users not shown)
Line 1: Line 1:
[[Category:Java]][[Category:How To]]
+
[[Category:Java ME]][[Category:SDK]][[Category:Eclipse]][[Category:Getting Started]]
 +
{{ArticleMetaData <!-- v1.2 -->
 +
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20070721
 +
|author= [[User:Hartti]]
 +
}}
 +
{{FeaturedArticle|timestamp=20100711}}
 +
Getting your first [[Java ME]] application ([[MIDlet]]) running on a real device requires a number of steps.  This Wiki page is a guide through that process.  As it is targeted at first-time MIDlet developers, some things are simplified, and more detailed information can be found elsewhere.
  
'''(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
+
== Is Java ME the right tool for your requirements? ==
  
==Analyze the situation==
+
[[Java ME]] is a limited subset of the standard Java ([[Java SE]]) available on the desktop computers, with some additional mobile phone-related APIs. 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 are 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 phone-book, video/audio recording, 3D graphics, etc.)
  
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
+
So first of all, before starting anything else, think whether Java ME is the right choice for you, or whether you should instead use Flash Lite for your application (runs both on Series 40 and S60 phones), or whether you should program in Python (S60 only) or in native Symbian C++ (for S60 phones only). (However, native C++ development for Symbian OS is quite tedious and error-prone, so just for productivity reasons, Java ME might be a better choice.)
* 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 [http://discussion.forum.nokia.com/forum/forumdisplay.php?f=3 Java Discussion Forums]. There is also documentation available on Forum Nokia web site, as well at [http://java.sun.com/javame/reference/index.jsp Sun Web site] and [http://www.ibm.com/developerworks/wireless IBM DeveloperWorks Web site].
+
If Java ME seems to be the way to go, you can find a lot of good information in this Wiki or in Nokia Developer's [http://www.developer.nokia.com/Community/Discussion/forumdisplay.php?3-Mobile-Java Java Discussion Forums]. There is also documentation available elsewhere on [http://www.developer.nokia.com/ the Nokia Developer website], as well at [http://www.oracle.com/technetwork/java/javame/documentation/index.html Sun Web site] and [http://www.ibm.com/developerworks/wireless IBM Developer Works 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).
+
== Overview of the development process ==
  
You can use what ever 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.
+
First note that you have to code, compile and package the MIDlet on your development computer. You cannot create a MIDlet on the phone itself (yet).
  
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 neede to run the application. The JAD file is atext file containg descriptive information about the MIDlet (size, needed APIs, MIDlet name, Vendor name, optonal signing information), which the phone (and user) can use to decide whether or not to donwload 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 :-)
+
To write MIDlet code, use whatever text editor or [[:Category:IDE|IDE]] (Integrated Development Environment) you prefer.  (But see the Nokia-supported IDEs below.) Then compile the code with the Javac compiler which comes with a Java SE SDK (JDK). Even though you do not need to worry about it right now, your code is also pre-verified at this stage.
  
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)
+
Before being able to install the MIDlet on a real device, you still need to package the MIDlet classes and resources to a [[JAR]] (Java Archive) file and generate a [[JAD]] (Java Application Descriptor) file. The JAR file contains all the code needed to run the application. The JAD file is a text file containing 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 strongly recommended to use both of the files to install the application.
  
==What tools to use and installing them==
+
At this stage, you can test the MIDlet on your development workstation using the phone [[emulator]], and then most probably make changes, then recompile and repackage it.  When you are satisfied with the result, you can transfer the generated JAR and JAD files to a real phone, install the app, and test it.  (You should always test a MIDlet on a real device before distributing it.)
  
You will be better off using a Windows-based computer for development as many of the phone SDKs needed do not work properly on Linux
+
You can also use some online resources to test your application on real devices, such [http://www.developer.nokia.com/Devices/Remote_device_access/ Remote Device Access (RDA)] or [http://www.deviceanywhere.com Device Anywhere].
  
JDK
+
You should also download other vendors' emulators (Motorola, Sony Ericsson, Samsung, etc.) and test your application using them.
  
Full-blown IDEs
+
== Required hardware ==
* Netbeans
+
* Eclipse ME
+
* etc
+
  
Phone SDK
+
The configuration of your computer depends on the tools you plan to use. Specific information can be found in each product's release notes or web site.
  
==Coding and compiling your first MIDlet==
 
  
(Will contain short code for HelloWorld MIDlet)
+
== Required software for S60 ==
  
==Running your MIDlet in the emulator and on real device==
+
For Java ME development for the S60 platform, the following tools are needed:
  
(Will contain packaged HelloWorld MIDlet for testing purposes)
+
* a [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java SE (Standard Edition) Development Kit (JDK)]
 +
* a Wireless Toolkit
 +
* a [http://www.developer.nokia.com/Library/Tools_and_downloads/Other/Symbian_SDKs/ Nokia Symbian/S60 SDK for Java]
 +
* an IDE that supports mobile Java development; popular ones are [http://netbeans.org/ NetBeans] and [http://eclipse.org/pulsar/ Eclipse Pulsar]
  
==Typical pitfalls==
+
For details of installing the required tools, see [[Installing Java ME development tools for S60]], as well as the information made available on the tools' web pages.
  
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
+
== Emulators and SDKs for Series 40 and Series 80 ==
  
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, however you cannot install a MIDlet with higher CLDC/MIDP version on the phone. Check the supported CLDC and MIDP versions on [http://www.forum.nokia.com/devices FN device specification pages].)
+
* [http://www.developer.nokia.com/info/sw.nokia.com/id/cc48f9a1-f5cf-447b-bdba-c4d41b3d05ce/Series_40_Platform_SDKs.html Java Tools for Nokia Series 40]
 +
* [http://www.developer.nokia.com/info/sw.nokia.com/id/449a2f84-2a8a-44fa-a7f4-93b53cb9c89a/Series_80_Platform_SDK_s_for_Symbian_OS_for_Java.html Java Tools for Nokia Series 80]
 +
 
 +
It should be noted that Series 80 is an old platform that is no longer supported by Nokia Developer.
 +
 
 +
{{Nokia SDK for Java}}
 +
 
 +
== Coding and compiling your first MIDlet ==
 +
 
 +
See [[Hello World in Java ME]], [[Creating your first MIDlet using EclipseME]], [[Developing MIDlets using Pulsar and Eclipse]] and [[NetBeans]].
 +
 
 +
== 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 [http://www.developer.nokia.com/Devices/ FN device specification pages].)
 +
 
 +
== See also ==
 +
 
 +
* The excellent [http://library.developer.nokia.com/ Nokia Developer Library] one of the best compilations of tutorials and documentation available

Revision as of 07:03, 28 September 2012

Article Metadata
Article
Created: hartti (21 Jul 2007)
Last edited: hamishwillee (28 Sep 2012)
Featured Article
11 Jul
2010

Getting your first Java ME application (MIDlet) running on a real device requires a number of steps. This Wiki page is a guide through that process. As it is targeted at first-time MIDlet developers, some things are simplified, and more detailed information can be found elsewhere.


Contents

Is Java ME the right tool for your requirements?

Java ME is a limited subset of the standard Java (Java SE) available on the desktop computers, with some additional mobile phone-related APIs. 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 are 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 phone-book, video/audio recording, 3D graphics, etc.)

So first of all, before starting anything else, think whether Java ME is the right choice for you, or whether you should instead use Flash Lite for your application (runs both on Series 40 and S60 phones), or whether you should program in Python (S60 only) or in native Symbian C++ (for S60 phones only). (However, native C++ development for Symbian OS is quite tedious and error-prone, so just for productivity reasons, Java ME might be a better choice.)

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


Overview of the development process

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

To write MIDlet code, use whatever text editor or IDE (Integrated Development Environment) you prefer. (But see the Nokia-supported IDEs below.) Then compile the code with the Javac compiler which comes with a Java SE SDK (JDK). Even though you do not need to worry about it right now, your code is also pre-verified at this stage.

Before being able to install the MIDlet on a real device, you still need to package the MIDlet classes and resources to a JAR (Java Archive) file and generate a JAD (Java Application Descriptor) file. The JAR file contains all the code needed to run the application. The JAD file is a text file containing 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 strongly recommended to use both of the files to install the application.

At this stage, you can test the MIDlet on your development workstation using the phone emulator, and then most probably make changes, then recompile and repackage it. When you are satisfied with the result, you can transfer the generated JAR and JAD files to a real phone, install the app, and test it. (You should always test a MIDlet on a real device before distributing it.)

You can also use some online resources to test your application on real devices, such Remote Device Access (RDA) or Device Anywhere.

You should also download other vendors' emulators (Motorola, Sony Ericsson, Samsung, etc.) and test your application using them.

Required hardware

The configuration of your computer depends on the tools you plan to use. Specific information can be found in each product's release notes or web site.


Required software for S60

For Java ME development for the S60 platform, the following tools are needed:

For details of installing the required tools, see Installing Java ME development tools for S60, as well as the information made available on the tools' web pages.

Emulators and SDKs for Series 40 and Series 80

It should be noted that Series 80 is an old platform that is no longer supported by Nokia Developer.

Announcements.pngNokia Asha SDK 1.0 (beta) (14 May 2013): Nokia Asha SDK 1.0 (beta) is available for download. This SDK enables you to target your Java apps at phones based on Nokia Asha software platform 1.0. SDKs for Series 40 (including Nokia SDK 2.0 for Java), can be downloaded from here.

Coding and compiling your first MIDlet

See Hello World in Java ME, Creating your first MIDlet using EclipseME, Developing MIDlets using Pulsar and Eclipse and NetBeans.

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.)

See also

918 page views in the last 30 days.
×