Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

MIDlet development with J2ME and MIDP

John Muchow, Author
John Muchow is the author of "Core J2ME Technology and MIDP", currently the best selling J2ME book at Amazon.com. Published by Sun Microsystems Press, it is a recent addition to the popular Java Series. John writes extensively about J2ME and maintains the wireless developer Web site Core J2ME. The site contains an abundance of source code, articles, developer tools, and resources, and links to the latest releases of J2ME software. John is also founder of The Wireless Mind, Inc., a business that provides training for wireless developers, specializing in J2ME. In the first quarter of 2002, The Wireless Mind will introduce online (Web-based) J2ME training.

Summary:  Nokia, the dominant player in the mobile phone market, has estimated that in 2002 it will sell over 50 million J2ME-enabled mobile phones. With lofty numbers announced by other mobile phone manufacturers as well, there is a flood of interest in software development revolving around J2ME (Java 2 Micro Edition). J2ME is a slimmed-down version of Java targeted at devices that have limited memory, display, and processing power. This tutorial provides a step-by-step introduction to downloading, installing, and configuring your computer to begin development of applications for this runtime environment.

Date:  04 Mar 2003
Level:  Introductory PDF:  A4 and Letter (172 KB | 21 pages)Get Adobe® Reader®

Activity:  5964 views
Comments:  

Parting shots

Keeping class files separate

Previously, we issued the following commands to compile and pre-verify our MIDlets:

javac -bootclasspath c:\j2me\midp1.0.3fcs\classes FirstMIDlet.java

preverify -classpath c:\j2me\midp1.0.3fcs\classes;. -d . FirstMIDlet

With this approach, the pre-verified class file overwrote the class file created by the compiler. For small applications, this is not much of an issue. However, as the complexity of your applications increase, so will the number of files that you need to juggle. One easy way to lend some organization is to place class files from the compiler and pre-verifier into separate directories.

Steps to separate class files:

#1 - Create new directories

Create directories with the names jclasses and pclasses.
These directories will hold the output from the compiler and pre-verifier, respectively.

#2 - Change command line syntax for compiler and pre-verifier

javac -bootclasspath c:\j2me\midp1.0.3fcs\classes -d jclasses *.java

preverify -classpath c:\j2me\midp1.0.3fcs\classes -d pclasses jclasses

-d jclasses informs the Java compiler to write the class files into the directory jclasses.
-d pclasses jclasses informs the pre-verifer to write the pre-verified class files into the directory pclasses. The reference to jclasses instructs the pre-verifier where to locate the class files to pre-verify.

#3 - Change command line for creating the JAR

jar cvfm MIDlets.jar manifest.txt -C pclasses . MIDlet1.png MIDlet2.png

-C pclasses . informs the JAR program to look in the directory pclasses and archive all (".") the files.

#4 - Load MIDlet suite

midp -classpath MIDlets.jar -Xdescriptor MIDlets.jad


J2ME Wireless Toolkit

Sun Microsystems provides a free J2ME Wireless Toolkit to simplify the development cycle when writing MIDlets. The toolkit manages project directories, compiles, pre-verifies, and packages MIDlets (creates the JAR and JAD). The toolkit also provides several emulators to preview MIDlets.

Download J2ME Wireless Toolkit at http://java.sun.com/products/j2mewtoolkit.

7 of 9 | Previous | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology
ArticleID=136853
TutorialTitle=MIDlet development with J2ME and MIDP
publish-date=03042003
author1-email=
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).