Java Platform Micro Edition
Java ME was designed by Sun Microsystems and is a replacement for a similar technology, Personal Java. Originally developed under the Java Community Process as JSR 68, the different flavors of Java ME have evolved in separate JSRs.
By default MIDlet is in the paused states. when the application is executed by default startApp() method will call and when close the application the destroyApp() method will be called.
Source code of
'jad' and 'properties' file
Java Application Descriptor (JAD) filename extension is .jad and media type is text/vnd.sun.j2me.app-descriptor, which developed by the Sun Microsystems, Inc.
J2ME Hello World Example
This is the simple hello world application. In this example we are creating a form name "Hello World" and creating a string message "Hello World!!!!!!!".
Creating MIDlet Application For Login in J2ME
This example show to create the MIDlet application for user login . All MIDlet applications for the MIDP ( Mobile Information Device Profile) derived from MIDlet class and it play a role as a mediator between the application and the environment in which the application runs.
Text Field MIDlet Example
This example illustrates how to insert text field in your form. We are using here two TextField (name and company). We are taking both TextField variable in to the constructor (TextFieldExample) of the class.
J2ME Contact List
This example illustrates how to create your phone book. In this example we are taking three SCREEN button ("Next", "New", "Exit") and taking two TextBox ("name", "number").
Date Field MIDlet Example
This example illustrates how to insert date field in your form. We are using here two fields DateField (datein and dateout) and initialize a final static variable DATE which is 0.
J2ME Button MIDlet
This example illustrates how to create command button in your form. Command class build to bind only the semantic information of the command it means command is not the actual action its contains only information about command.
J2ME CheckBox ChoiceGroup MIDlet
This example illustrates how to create check boxes in to your form. In this example we are creating a Form("Technologies") that is having four different choices, ChoiceGroup("JAVA", "J2ME", "J2EE", "JSF").
A MIDlet Example to execute Alert Message with an Image
In this "Alert Message" example, you will learn how to send an alert message to user whenever an action is called. The example have two different options 1. "ok" and option 2. "Cancel".
J2ME Alert Example
This example illustrates how to create alert through sound. In this example we are using AlertType class for the different alert.
Radio Button in J2ME
In this tutorial you will see the MIDlet Example that is going to demonstrate, how to create the radio button in J2ME using MIDlet. The radio button is use to choose only one option at a time.
J2ME List Image
This example illustrates how to create list with image symbol. In this example we are trying to create list using of List class.
List in J2ME
This example illustrates how to create a Exclusive List. The Exclusive List is used to select only one list element at a time.
J2ME Canvas Example
This example illustrates how to create a game using GameCanvas class. In this example we are extending GameCanvas class to draw the circle and rotate the circle continuously.
Creating Canvas Form Example
This example shows that how to use the Canvas Class in a Form. In this example we take two field in which integer number passed from the form and result will display on a Canvas circle.
Creating Menu Using Canvas Class
This example shows how to create the menu and call the canvas class to show the toggle message.
Creating Multiple Type List
This example is shows how to create the list which has multiple type choice option.
J2ME Ticker Example
This is the simple Ticker example which is used to auto scroll the data on the top of the form. It continuously scroll the data.
J2ME Thread Processing Example
In the given example, you will learn about the thread and how thread works in J2ME application. An application can run multiple activities simultaneously using thread. Here we have defined different states of thread...
Draw Line in J2ME
In this example we are going to show you how to draw a line using J2ME. Please go through the below given J2ME syntax that includes all the package, methods and class to draw a line.
Draw Rectangle in J2ME
In this series of J2ME examples and tutorials, we have introduced you with it's various features with examples. Now in the given example, you will learn about creating rectangles in J2ME.
Draw Font Using Canvas Example
This example is used to draw the different types of font using Canvas class. The following line of code is used to show the different style, size and faces of font.
Draw String Using Canvas
This example is used to draw string on different location which is shown in figure. The given code is used to show, how to draw string at different locations.
Interactive, Non-Interactive Gauge Example
This example shows, how to create the Gauge class to draw the interactive and non-interactive gauge which is used to display the volume label.
Creating Volume Bar Using Gauge Class
This example is all about creating a volume bar using Gauge class. We are creating the object of Gauge class that contains the following parameters label, interactive, maxValue and initialValue and it has been set with the form.
Image Item Using Canvas Example
This example is will show you how to create the image at the top center of the screen.
Image Icon Using Canvas Example
This Example is going to draw a clip with SOLID line. In this picture only solid line show the clipping area.
Draw Clip Area Using Canvas
This Example is going to draw a clip with SOLID line. In this picture only solid line show the clipping area.
Player Class in J2ME
In J2ME, player class is used to play the .wav music, that is the only reason of using the class in our small application to create multimedia sounds.
Draw arc in J2ME
The given example is going to draw an arc using canvas class of J2ME. You can also set a color for it, as we did in our example.
Building a J2ME sliding menu with text and images(part-1)
This example will show, how to create an image icon to perform the next action or next image from the list every time it's been clicked. So if you want to go from one icon to another icon by the nice sliding effect, you have to run the given example.
Building a J2ME sliding menu with text and images(part-2)
In the given J2ME Menus example, we have explained to create two different buttons that is going to perform as a back and forward buttons.
Video Player MIDlet Example
This example is all about how to play the MPEG files on your mobile device. To play the video file we have to import the javax.microedition.media.control package and certain sub-package that are required for the application.
User Define Alert Example
Creating a user defined alert message, In the given example we have created a image that can be fill with some colors and text. The following source code shows how to create the image, how to set the color and how to draw string.
Ring Tones MIDlet Example
In this example only two Ring Tones are created using Player class.
This type of example is basically used in touch screen technology, here we are trying to create a pointer which location is based on the screen touch pointer.
Media MIDlet Example
Creating more then one player in a MIDlet, Here we have created an 'item' object for Hashtable and put all 'wav' file in this table with object 'key' and object 'value' which maps the keys to value.
Get Help MIDlet Example
This example illustrates how to take help from any other text file which is stored in res folder in your MIDlet. In this example we are creating a form which name is "New Form".
Different Size of Font MIDlet Example
This example simply shows the different size of font.
Audio MIDlet Example
This example illustrates how to play audio songs in your mobile application by creating a MIDlet. In the application we have created a player for an audio song by using of
This example is used to access the data from the specific url. The Stream Connection is used to connect the application to the specific url by Airtime (connect to the internet).
Text MIDlet Example
With the help of text MIDlet example, we are going to show text using canvas class at different locations on the screen.
Arc MIDlet Example
In the previous draw arc example, we have explained how to draw an arch on the screen. But in this example we are going to show how to draw arc at different locations.
Simple Line Canvas Example
This is a simple example of drawing lines using canvas class in J2ME. In this example we are creating three different lines at different locations and form.
Graphics MIDlet Example
This is the another graphic example, where we are going to draw a image that look and act like satellite and earth. For creating these types of graphics in J2ME we use MIDlet's.
Rectangle Canvas MIDlet Example
The example illustrates how to draw the different types of rectangle in J2ME. We have created CanvasRectangle class in this example that extends to the Canvas class to draw the given types of rectangle.
J2ME Draw String
In the previous examples, we learned about drawing different graphics on the screen. Here in this example, we are going to show the string in J2ME.
In this example, we are going to draw to different lines which cross to each other on the center of the mobile window using Canvas class. "CanvasCrossLine" class created by us extends the Canvas class to draw both the lines.
With the help of the canvas class, we can draw as many as graphics we want in our application. Similarly we can also set the different alignment to the text.
Text Example in J2ME
In J2ME programming language canvas class is used to paint and draw the diagrams. Using the same canvas class we are going to draw a box around the text in our show text MIDlet Example.
J2ME Canvas KeyPressed
This tutorial is going to show you how to handle keypressed event in J2ME using canvas class. After going through the given example, you will be able to show different output against different keypressed actions.
In this example the CoordinatesCanvas class extends the Canvas class to draw the image and fill color as given below in the figure.
J2ME Record Store MIDlet Example
This is a simple program to record data and print it on the console.
J2ME Animation using repaint( ) method
In this part of J2ME Image Tutorial, we are going to show you how to create an Image with animation. Here we have create a class called ImageAanimation that extends MIDlet and implements the CommandListner class.
Immutable Image MIDlet Example
This is the immutable image example, which shows how to create a immutable image in MIDlet. In this example we are creating a image without using of canvas.
Immutable Image using Canvas Class
This is the immutable image example which shows how to create the immutable image using canvas. In this example ImageCanvas class extends the Canvas class to create the immutable image.
This is the Mutable image example which shows how to create the mutable image using canvas class.
J2ME Draw Triangle, Rectangle, Arc, Line Round Rectangle Example
In this serious of J2ME tutorial, we are going to describe how to draw a triangle, rectangle, arc, line or a round rectangle in one small application. Although we have already explained you all these examples separately but in this section we are going to merge them in one.
List in J2ME
J2ME Canvas List Example will explain you, how to create list of items. In this example we are going to create a simple list of text, that will show the selected item on the same screen.
J2ME Calendar Application
J2ME Canvas Repaint
In J2ME repaint is the method of the canvas class, and is used to repaint the entire canvas class. To define the repaint method in you midlet follow the given syntax.
J2ME Crlf Example
The given J2ME Midlet, discuss about how to show the messages in different line and row. In this example we have created an object called clrf that is further used to break line and row to show the message in correct readable format.
J2ME Command Class
In the given J2ME Command Class example, we have set the various commands namely, screen, back, cancel, ok, help, stop, exit and item to the Midlet.
J2ME Record Store Example
In this Midlet, we are going to read string data and write by using the RecordStore class. The package of the RecordStore class is the javax.microedition.rms.
J2ME Form Class
In this J2ME Extends Form example, we are going to discuss about form, extending form in our class and appending values to it.
J2ME Current Date And Time
This is a simple J2ME form example, that is going to show the current date and time on the screen. Like core Java J2ME too use the same java.util package to show the current date as well as current time on the screen.
J2ME Display Size Example
In the given J2ME Midlet example, we are going to display the size of the screen. Like a below given image 1, the midlet will print few items on the screen and the screen size will be displayed at the command prompt (image 2).
J2ME Enumeration Example
Enumeration is an Interface that comes with the java.util package that can be implement by an object. After going through the example you will be able to run a video file using interface enumeration in J2ME.
Appending string in J2ME Form
In the previous example, you learned about how to add items in to the form. In this example we are going to add string into the form. Both examples are almost same but the only difference is that this time we are using append string instead of append item.
J2ME Draw Triangle
As you already aware of the canvas class and it's use in J2ME application, we are using canvas class to draw the triangle on the screen. In this example you will learn how to draw a triangle and filling it with particular color
J2ME Convert Date To String
As in the previous example, you have learned about how to print the current date on the screen. But in this example we are going to convert the date into string.
Appending Image into the J2ME Form
After adding item and string, now we are going to add image into the J2ME Form.
Custom Item in J2ME
In J2ME applications, Custom Items can be created by programmers and they can also set their look and feel as these custom item have their own method called paint().
J2ME Timer MIDlet Example
This Example shows how to use of timer class. In this example we are using the Timer class to create the time of execution of application and the TimerTask class is used to create the counter of timer which is executed after 5000 ms
J2ME RMS Sorting Example
This example simply shows how to use of RMS package. In this example we are going to sort the specified string by the implementing of RecordComparator
J2ME Read File
In this J2ME application, we are going to read the specified file.
J2ME Random Number
In this application we are going to generate the random number using Random class. The Random class within the java.util package and we can use it by importing the java.util.Random package.
J2ME Label Example
This is the simple create label example in which we create an StringItem to display the "UserId" as a label text. In the given application we are using setLabel to set the new label to the ItemString.
J2ME KeyEvent Example
This application illustrates to find the key code of each key with its value.
J2ME Key Codes Example
This application illustrates how to print the key value with the current key pressed on the canvas.
J2ME Item State Listener Example
In this application we are going to shows how to implement the ItemStateListener interface in the j2me midlet.
J2ME Image Example
In this application we are going to simply create an image using canvas class. In this class we are creating the image and a thread to run the image.
J2ME Image Item Example
This application illustrates how to create the image and imageItem using Image and ImageItem class respectively. In this example we are going to create an image using Image Class and imageItem using ImageItem class.
J2ME Icon MIDlet Example
In this example we are going to create icon list of different sizes. We are creating here a IconList class, in this class we inherited the property of List class.
J2ME HashTable Example
To use the HashTable, java.util.Hashtable package must be imported into the application. Generally HashTable are used to map the keys to values and these keys or values could be any null object.
J2ME Event Handling Example
In J2ME programming language, Event Handling are used to handle certain type of events that are generated at the time of loading MIDlet on the mobile screen.
J2ME Video Control Example
This Application explain the use of Video Control. The work of video control is used to controls the display of video.
J2ME Vector Example
This application illustrates how we can use Vector class. In this example we are using the vector class in the canvas form.
J2ME Timer Animation
This application illustrates how to use the Timer class and implement it in the canvas class. In this Tutorial we have given you a good example, which helps you to understand using of timer class for drawing the canvas.
J2ME Text Box Example
This application illustrates how to create the text box using TextBox class. The TextBox class is a Screen that allows the user to enter and edit text.
J2ME Record Listener
This application illustrates to implement the RecordListener interface with the RecordStore class for receiving Record Changed, Added, Deleted events from a record store.
J2ME Audio Record
This example is used to record the audio sound and play the recorded sound.
J2ME Record Data Base
This Application is used to explain how to store data in the database. In this example we are going to import the javax.microedition.rms package to access the RecordStore class.
J2ME RMS Read Write
This Application specially tries to explain how to read and write the data using RecordStore class.
J2ME Frame Animation
This application shows to set the Frame Animation and implement it in the canvas class. In this example we are creating a frame using Gauge class.
J2ME Frame Animation2
This example illustrates same as in the previous example, but here we are creating four blocks and set five frame manually. The whole example shows you to create the frame and blocks.
J2ME Cookies Example
This Application is used to find the cookies value of the servlet. In this example we are creating a MIDlet (
for access the servlet.
J2ME Servlet Example
This is the simple servlet tutorial. In this tutorial we shows you, how to create the servlet and implement it with the midlet.
Liked it! Share this Tutorial