Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Equinox Demos"

Line 62: Line 62:
 
==[http://www.savaje.com SavaJe]==
 
==[http://www.savaje.com SavaJe]==
  
We also have a [http://www.savaje.com SavaJe] phone...haven't done anything cool with it yet though.
+
We also have a [http://www.savaje.com SavaJe] phone...haven't done anything very cool with it yet though.
 +
 
 +
===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 [http://eclipseme.org/ Eclipse ME], a plugin for Eclipse. As the homepage states, you can install this plugin really easily by setting a remote site, with http://eclipseme.org/updates/ as the URL.
 +
 
 +
====Using Eclipse ME====
 +
Once you have EcliseME installed, you'll need to set it up. The website provides good [http://eclipseme.org/docs/index.html documentation], but here are some highlights
 +
*You'll need to set up at least one device configuation. (<code>Window -> Preferences -> J2ME -> Device Management -> Import</code>)
 +
*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.
 +
 
 +
====Deploying the Midlet====
 +
Once you've written a Midlet to your satisfaction, you may want to test it on an actualy phone. To deploy your midlet, bring up the context menu on your Midlet project, and select <code>J2ME -> Create Package</code>
 +
 
 +
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 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.

Revision as of 13:08, 4 October 2006

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

XML

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:

osgi.framework.extensions=org.eclipse.ercp.xmlParserAPIs,org.eclipse.ercp.xml

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 = \
 javax.microedition.io
org.osgi.framework.bootdelegation = \
 javax.microedition.io
org.osgi.framework.executionenvironment = \
 OSGi/Minimum-1.0,\
 OSGi/Minimum-1.1,\
 CDC-1.0/Foundation-1.0,\
 CDC-1.0/PersonalProfile-1.0,\
 CDC-1.1/PersonalProfile-1.1
osgi.java.profile.name = 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:

osgi.java.profile=file:d:/temp/ppro.profile

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.

Extras

  • j9 -io:host:port
  • console telnet

Networking

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.

SavaJe

We also have a SavaJe phone...haven't done anything very cool with it yet though.

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 http://eclipseme.org/updates/ 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.

Deploying the Midlet

Once you've written a Midlet to your satisfaction, you may want to test it on an actualy 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 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.

Back to the top