Skip to main content
Jump to: navigation, search

Equinox Demos

Revision as of 12:54, 13 October 2006 by (Talk | contribs) (Deploying the Midlet)

Nokia 9300 Communicator

Local Machine Setup

The first thing you need to do is ensure that your machine can talk to your phone. We used Bluetooth for our communications. We also downloaded and installed the Nokia PC Suite so we could use the File Manager tool for transfering files from your local machine to the phone.

Java on the phone

The Java VM on the phone is J9 Personal Profile 1.0 (ppro10) Well, that was the VM on our phone. :-)

Java on your local machine

To make things easier, we set up the demos on our local machine, ensured they were working ok, and then transfered them to the phone. So the first thing we had to do was ensure that we had the right VM set up locally.

  • First you need to download the Foundation 1.0/Personal Profile 1.0 VM.
  • Add the VM as an Installed JRE (Window -> Preferences -> Java -> Installed JREs).
  • Add the 2 extra libraries as external JARs (ppro-ui.jar, ppro-extras.jar).
  • Add the following default VM arg: -jcl:ppro10.

Running a Java application on the phone

  • The file-system can be referenced like Windows with C: and D: (the D: drive is the memory card).
  • The J9 VM is associated with the .j9 file-type. You create a .j9 file with all the command-line arguments for your application and then when you click on it in the file manager it will run J9.
  • The file contains everything that you want on the command line except the reference to the VM executable. e.g.
-cp foo.jar com.Foo
  • Note: any arguments after the class name on the commandline are passed to the class as arguments to the application and are not interpreted by the VM. Therefore if you are trying to set system properties, it should be done early in the command-line. e.g.
-Dfoo=bar -cp foo.jar com.Foo
  • Use the file manager on the phone to select the .j9. Opening it will launch the Java application.

Running an Eclipse Application on the phone


Since Eclipse uses an XML parser to read the registry and other files, you will need to get bundles that provides the XML Parser APIs. A good candidate for this are 2 bundles (org.eclipse.ercp.xml, org.eclipse.ercp.xmlParserAPIs) which are included as part of the eRCP project. These two bundles are created as framework extensions so you need to tell OSGi about them by setting a system property:


Personal Profile EE

Now when you try and run, you will likely get an exception saying that OSGi couldn't match the required Execution Environment for some of the bundles. They are looking for the Founation 1.0 EE but the current VM doesn't match this. So we need to create a new profile which looks like this:

org.osgi.framework.system.packages = \
org.osgi.framework.bootdelegation = \
org.osgi.framework.executionenvironment = \
 CDC-1.1/PersonalProfile-1.1 = CDC-1.0/PersonalProfile-1.0

Next we need to set a system property for the new profile which contains a file URL to the location of the file:

Writing to the Console

  • C:/logs/j9vm - You must have this directory created or your Java application will hang when it tries to write something to System.out or System.err.
  • When you run your Java application 2 files will be created in this directory, one for System.err and one for System.out.
  • The files will be named <pid>_syserr.txt and <pid>_sysout.txt
  • Output will always be to this directory, even if your JAR files are on a different drive.


  • j9 -io:host:port
  • console telnet


In order to set up the phone for a demo, we wanted an IP address. The best way to do this (since you don't know where you are going to give a demo or the network status when you are at that location) is to set up an adhoc network on your local machine and then connect to it from the phone.


We also have a SavaJe phone.

Connecting to the phone

The most convenient way to connect to the phone is to use the USB cable. To get this to work, I needed to update my drivers. I got updated drives from Instructions for installing the drives can be found in the documentation accompanying the phone, and online at the SavaJe Wiki. In short, you need to:

  • UnZip the drivers to a temporary location
  • Navigate to this location in the command prompt
  • type Setup -ignore_serialnum (This worked for Windows)
  • Follow the onscreen directions, then plug the phone into your computer, and (on Windows) the install wizard will take care of the rest.

Writing a Midlet

Local Machine Setup

We want to write a simple Midlet for the Jasper S20 phone. First, we need a suitable development environment to write, and test, the midlet locally on our machine. To do this, we installed Eclipse ME, a plugin for Eclipse. As the homepage states, you can install this plugin really easily by setting a remote site, with as the URL.

Using Eclipse ME

Once you have EcliseME installed, you'll need to set it up. The website provides good documentation, but here are some highlights

  • You'll need to set up at least one device configuation. (Window -> Preferences -> J2ME -> Device Management -> Import)
  • In our case, we got the configuration file from the Midlet Toolkit 1.0 that came with the developper version of the phone. We chose the configuration with the name SavaJePhoneA
  • EclipseME will add options to create a new Midlet Suite, and to create a new Midlet. Using the 'New Midlet' command just creates a standard java class that extneds the MIDlet class

Deploying the Midlet

Once you've written a Midlet to your satisfaction, you may want to test it on an actual phone. To deploy your midlet, bring up the context menu on your Midlet project, and select J2ME -> Create Package

In your midlet project, there should be a folder called deployed. In that folder, there should now be two files [project name].jad, and [project name].jar. Place these two files in a directory, on your phone's memory expansion card, called MidletInstall (We placed the two files in a subdirectory named after the project, but I'm not sure what effect, if any, this had). Next replace (or remount) the memory card back in your phone, and open the Application Manager in the Utilities menu. You should see your Midlet in the list of applications to install.

Writing an Xlet

Local Machine Setup

There isn't currently an eclipse plugin for creating Xlets, so a little more manual work is required. First, we got a suitable JRE. We chose to use Personal Profile 1.1, which we downloaded using instructions from the J9 page. The only difference is that in step 7 we chose 1.1, isntead of 1.0. Also take note of the last part of that article, Foundation 1.1. It applies to Personal Profile 1.1 as well. Once you install this JRE into eclipse, you'll probable need to add ppro-extras.jar, and ppro-ui.jar, using Add External Jar. Ppro-ui.jar, in particular contains the Xlet class, which your main class needs to implement.

Using Elcipse

To set up a project in our workspace, we created a standard Java project, and chose PPRO1.1 as the associated JRE. Our particular project required Swing classes, so we added SavaJeDevelopper.jar as a library (This came with the developper version of the phone). When writing an Xlet your main class should extend the Xlet class.

Deploying the Xlet

To run your Xlet on the phone, create a directory called savaJe/bundles on the memory expansion card. Inside this directory create a directory named after your Xlet project. Inside this directory, you'll need a file called bundle.jnlp, a file called bundle.policy, and a fodler called lib. Next, export your Xlet project as a JAR file. You will not need to export the .classpath or .project files, os uncheck those. Name the file classes, and choose to export it to your lib directory.

.policy file

My .policy file looked like this:

grant codeBase "sb:/VmCheck/lib/classes.jar" {

VmCheck is the name of the directory We created in savaJe/bundles, it's also the directory containing the .policy file. You should modify your .policy appropriately.

.jnlp file

My .jnlp file looked like this:

<?xml version="1.0" encoding="utf-8" ?>
<jnlp codebase="sb:///VmCheck/">

    <j2se version="1.4+"/>
    <jar href="lib/classes.jar"/>


  <application-desc main-class="org.eclipse.savaje.simplexlet.SimpleXlet">

  • The <jnlp codebase> tag contains the name of the root directory for the Xlet.
  • the <jar href> is a relative url to your exported project, from the root directory
  • the main-class in the <application-desc> tag is the name of your Xlet class within the JAR file.

We're not entirely sure how strictly you have to adhere to conventions like having the lib directory, and the JAR file being called classes.jar, but we had some difficulty getting our test program to work, so we decided to follow the conventions established in the example Xlets that came with our phone.

Running a normal Java application

Normal java files can be run using JNLP, similarly to xlets. That is, having a bundle.jnlp file, a bundle.policy file, and a folder called lib with the jar'ed classes you want to run. As far as we can tell, the jar file that has the entry point to your java application has to be called classes.jar, and has to be in the lib folder.

You can add classes and jars to the class path using the jar href tag: <jar href="lib/addon.jar"/> In this example, addon.jar is not located in the subfolder lib, as you might except. Instead, it is located in C:\home\Output\lib (I:\ is the drive name for the memory card, on the phone that would appear as /cf0/home/Output/lib).

System properties can be set using the property tag: <property name="[property name]" value="[property value]"/>

Back to the top