XmlBlaster Logo



XmlBlaster Logo

Type NEW
Priority LOW
Topic XmlBlaster provides a tiny java client library for j2me MIDlets

If you develop j2me applications you can connect with our tiny client java library which is specific to applets and j2me applications.


  • Supports complete xmlBlaster access including real time asynchronous callbacks.
  • The communication protocol is based on a persistent http connection which is used to push back callback messages
  • Reports exceptions nicely back to the client


The following illustration shows a typical use case, a MIDlet running for example in a cellular phone or in a PAD contacts the Web Server, for example Apache, which directs the call to a servlet engine with xmlBlasters communication servlet. The servlet looks at the applet request and opens a connection to xmlBlaster to delegate the request.

Supported MIDget methods are

Online demo

If your mobile supports MIDlets, try it online with this URL: http://www.xmlblaster.org:8080/xmlBlaster/j2me/SystemInfo.jad

NOTE: If you compile with JDK 1.5 final release the SystemInfo.jar application fails when loaded by the emulator, you need to force to 'javac -source 1.4 -target 1.4'. If you use our build.xml this is enforced already.


There is a little demo showing the way this works. The demo SystemInfo has the same functionality as the SystemInfoApplet. In order to be run it needs a running xmlBlaster (with the xmlrpc port redirected or disactivated), a SystemInfoPublisher which publishes on the given xmlBlaster and a servlet engine running (for example apache's tomcat). If you don't want to bother about configuring and starting these, you can use the ones which constantly run on the xmlBlaster server. The url of the servlet is http://www.xmlBlaster.org:8080/xmlBlaster/AppletServlet.

If you have access to an embedded device which supports j2me (and more precisely CLDC-1.1 and MIDP-2.0 profile) you can download the precompiled demo application directly from the xmlBlaster server:

And you can then run the application (check/adjust the URL in SystemInfo.jad before).

If you are not that lucky of having such a device you still can try this demo out by using an emulator. You can download sun's j2me development kit which allows you to compile the applications yourself. You can find it at Sun's j2me pages. Once you have downloaded it install it in a directory of your choice. Lets say you install it on ${J2ME_HOME}.
To compile the application you then invoke:

   build -DJ2ME_HOME=${J2ME_HOME} j2me
to run the application run:
   ${J2ME_HOME}/bin/emulator -Xdescriptor ${XMLBLASTER_HOME}/demo/j2me/SystemInfo.jad
and an application similar to this should appear:


Quick start installation of the server side stuff (if you want the server to be run locally)

You can try it with tomcat locally (no apache is necessary, i had tomcat 3.2.4, 4.1.29 and 5.0.14 to test it, others should work as well):

1. Create a war file:

The $TOMCAT_HOME/webapps/xmlBlaster.war file contains all necessary servlets and xmlBlaster client library to forward requests to xmlBlaster. You can have a look at the configuration in xmlBlaster/demo/http/WEB-INF/web.xml before creating the war file.

  cd xmlBlaster

  build  -DTOMCAT_HOME=/opt/jakarta_tomcat   deploy_war

Set TOMCAT_HOME to point to your installation and the xmlBlaster.war will be automatically deployed to $TOMCAT_HOME/webapps/xmlBlaster.war

2. Start the xmlBlaster server and a demo publisher (keep port 8080 free for tomcat)

  java org.xmlBlaster.Main -plugin/xmlrpc/port 8081   
  java  http.dhtml.systemInfo.SystemInfoPublisher

3. Start the tomcat web server

The $TOMCAT_HOME/webapps/xmlBlaster.war was created and copied already in step 1.

 cd $TOMCAT_HOME/bin

4. Create the jar file which is transferred to the mobile device

 build j2me

The result is xmlBlaster/demo/j2me/SystemInfo.jar and xmlBlaster/demo/j2me/SystemInfo.jad.

Edit your SystemInfo.jad file

You need to add the URL which points to the SystemInfo.jar file and to the servlet AppletServlet to the SystemInfo.jad file:
MIDlet-1: SystemInfo, SystemInfo.png, SystemInfoMidlet
MIDlet-Info-URL: http://www.xmlblaster.org/xmlBlaster/doc/requirements/client.j2me.html
MIDlet-Jar-Size: 27299 
MIDlet-Jar-URL: http://localhost:8080/xmlBlaster/j2me/SystemInfo.jar
MIDlet-Name: SystemInfo
MIDlet-Vendor: www.xmlBlaster.org
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-1.0
servletUrl: http://localhost:8080/xmlBlaster/AppletServlet

Now copy

the xmlBlaster/demo/j2me/SystemInfo.jar and xmlBlaster/demo/j2me/SystemInfo.jad file to be available on the web server (tomcat):

   mkdir $TOMCAT_HOME/webapps/xmlBlaster/j2me
   cp ${XMLBLASTER_HOME}/demo/j2me/SystemInfo.ja? $TOMCAT_HOME/webapps/xmlBlaster/j2me

5. Watch the result with your mobile

Start the emulator or if you have a mobile device somehow connected to you computer run it:

   ${J2ME_HOME}/bin/emulator -Xdescriptor ${XMLBLASTER_HOME}/demo/j2me/SystemInfo.jad
   ${J2ME_HOME}/bin/emulator -Xdescriptor http://localhost:8080/xmlBlaster/j2me/SystemInfo.jad



For convenience the Urls of SystemInfo.jad can be passed to ant and will be replaced as shown above:

   build -DJ2ME_HOME=/opt/WTK2.1 


If the emulator says 'Warning: Failed to initialize WMA message routing support' try setting write permissions to your J2ME directory:

chmod a+rwx ${J2ME_HOME}
chmod a+rwx ${J2ME_HOME}/appdb
Configure If you want to setup an http server from which be able to download your application, you have to make sure the server recognizes the jad and the jar files as mimetypes. For an apache server this means that the configuration file (default httpd.conf) contains the lines:
AddType text/vnd.sun.j2me.app-descriptor .jad
AddType application/java-archive .jar
and then restart the apache server. More about "Over The Air" (OTA) Provisioning can be found here.

NOTE: Configuration parameters are specified on command line (-someValue 17) or in the xmlBlaster.properties file (someValue=17). See requirement "util.property" for details.
Columns named Impl tells you if the feature is implemented.
Columns named Hot tells you if the configuration is changeable in hot operation.

See API org.xmlBlaster.client.protocol.http.common.I_XmlBlasterAccessRawBase
See REQ interface
See REQ client.browser
See REQ client.java.applet
See Mobile development kits from Sun
See http://jakarta.apache.org/tomcat/
See http://www.xmlBlaster.org:8080/xmlBlaster/index.html
See http://www.xmlBlaster.org:8080/xmlBlaster/HelloWorld3.html
See http://www.xmlBlaster.org:8080/xmlBlaster/SystemInfoApplet.html
See Emulator from Nokia
See Emulator from Motorola

This page is generated from the requirement XML file xmlBlaster/doc/requirements/client.j2me.xml

Back to overview