Just An Application

September 11, 2009

“MIDlet not constructed by createMIDlet.” ?

Filed under: Java, JME, MIDlets, MIDP, MIDP Implementation, Mobile Java — Tags: , , , , — Simon Lewis @ 11:23 am

This is a bit of a meta or recursive post in a way because it is prompted by my curiousity as to why the phrase

MIDlet not constructed by createMIDlet.

keeps turning up in the list of search terms used by people who have ended up here.

It is not really a generic term like some of the others which bring people here. For example



MIDlets on Android

or variations thereof.

It is pretty specific, and it is the same phrase everytime, but It is not one I’ve ever used here. So what does it match here and what is everyone looking for ?

Finding out what the search engines are matching here is easy enough. Type it in and see what they reference. The answer is this post

      What’s New In MIDP 3.0 ? Part 10: The MIDlet Lifecycle

which contains the terms “constructed”. “create”, and “MIDlet()”. Hence the match, but obviously not very useful given the actual search term.

Where does the search term itself originate ? Judging from some of the other search results it is an error message associated with a SecurityException thrown by Sun’s MIDP implementatation, so I’m guessing that people are seeing this exception and want to know what causes it.

The answer I suspect is that they are trying to create a MIDlet programatically and you are not allowed to do that as it says in the Throws clause of the documentation for the javax.microedition.midlet.MIDlet constructor

java.lang.SecurityException – unless the application management software is creating the MIDlet.

There are a good reasons for not allowing this. It would be very hard if not impossible to implement MIDP and ensure the correct lifecycle behaviour if MIDlets could be constructed programmatically.

Ironically it is actually pretty tricky to prevent it happening as well. As an implementor the only hook you have is the javax.microedition.midlet.MIDlet constructor which is in what is effectively a sealed package, but it can be done.

If you want to see exactly how Sun did it you can download their MIDP implementation as part of Phoneme Feature or Phoneme Advanced.

If you want to see how we (Symbian) did it, well unfortunately currently you can’t, which is a shame, because it was quite clever. Well at least I thought so, but then I would.



  1. I am facing a similar problem. I made a midlet called startup from which i am making object of another class extending MIDlet called client. This object will be created only when i select it on the emulator and press ok. On pressing ok i get a SecurityException with a message something like constructor not created by createMIDlet.
    Can any one please help!!!

    Comment by Soumya Tejas — January 20, 2010 @ 11:31 am

    • i’m afraid you cannot do that. The MIDP specification is very emphatic on the subject

      The application management software is responsible for creating
      MIDlets and creation of MIDlets is restricted. MIDlets should not
      attempt to create other MIDlets.

      Your client object should sub-class something else unless it is a MIdlet
      in its own right, in which case you do not get to construct it



      Comment by Simon Lewis — January 20, 2010 @ 12:18 pm

  2. […] the subject of this post, it originates in the company formerly known as SUN‘s MIDP […]

    Pingback by “No MIDlet-<n> registration” ? « Just An Application — March 27, 2011 @ 9:36 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at WordPress.com.

%d bloggers like this: