MIDlet Suite

Back | Next

A MIDlet Suite consists of multiple MIDlet's in a single JAR file. There will be multiple classes extending MIDlet class and all the other supporting classes within the JAR file can be accessed by these multiple MIDlets.

The main advantage using MIDlet Suite is sharing of data and resources between multiple MIDlets. These resources are

  1. Other Classes
  2. Images
  3. Resource Files
  4. RMS(Record Management System)

This simple HelloWorld example will guide you through creating a MIDlet Suite. This Suite has Three MIDlets

This suite will also has a Helper class HelloWorldForm which will be used by the above three midlets.

Code Segment of FirstMIDlet.java

public class FirstMIDlet extends MIDlet{

    public FirstMIDlet() {

    	HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 1", this);
    	Display.getDisplay(this).setCurrent(helloForm);

    }

Code Segment of SecondMIDlet.java

public class SecondMIDlet extends MIDlet{

    public SecondMIDlet() {

    	HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 2", this);
    	Display.getDisplay(this).setCurrent(helloForm);

    }

Code Segment of ThirdMIDlet.java

public class ThirdMIDlet extends MIDlet{

    public ThirdMIDlet() {

    	HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 3", this);
    	Display.getDisplay(this).setCurrent(helloForm);

    }

Only difference between these three classes is the first parameter of the HelloWorldForm() constructor call.Now Let us look at the Code Segment of HelloWorldForm.java

public HelloWorldForm(String greeting, MIDlet midlet) {

    	super("MIDlet Suite");
    	this.midlet = midlet;
    	exitCommand = new Command("Exit", Command.EXIT, 1);
    	this.append(greeting);
    	this.addCommand(exitCommand);
    	this.setCommandListener(this);
}

This class extends a Form and displays greetings sent by the MIDlets. HelloWorldForm is used by all the three midlets. No other MIDlet outside this JAR file can use it. You Can Configure a MIDlet suite in your WTK by adding extra MIDlets in the Setting pane's MIDlets Tab.

MIDlet Suite Configurations

These MIDlets get Configured in JAD file as MIDlet-1, MIDlet-2, MIDlet-3,......

Due to These configurations now your MIDlet has got three entry points. And the AMS takes care of this ambiguity and presents you with all these three MIDlets as Menu Items.

MIDlet Suite Display

MIDlet Suite helps us to share resources only within the same JAR file. Other security restriction remain intact, A MIDlet cannot access resources from other JAR files.

j2meSalsa goodies
Execute MIDlet Suite Demo online You have been executing MIDlet suite from the beginning of this tutorial. All the demo applications are packaged as MIDlet Suite on the online emulator.
View Java source code
Download this code for deploying directly to WTK Click here to download Zip File Containing WTK compatible file structure.

Back | Next

site comments powered by Disqus

This page is a part of a frames based web site. If you have landed on this page from a search engine click here to view the complete page.