Skip Headers
Oracle® Java ME Embedded Getting Started Guide for the Windows Platform
Release 3.4
E35132-03
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

A Running Sample Applications

This section describes how to use demos in the Oracle Java ME SDK platform. Because IMP-NG is headless, you can observe the running status of an application in the following ways:

Sample applications are available in two ways:


Note:

Before using the Oracle Java ME SDK demo applications, see "Installation and Runtime Security Guidelines" in Appendix C. Some demos use network access and open ports, and do not include protections against malicious intrusion. If you choose to run the sample projects, you should ensure your environment is secure.


Using the Oracle Java ME SDK Update Center to Get Sample Applications

The Oracle Java ME SDK Update Center is a part of the Oracle Java ME SDK product distribution and is used only for updating Oracle Java ME SDK components.

To run the Oracle Java ME SDK Update Center:

  1. Go to the location where you have installed the Oracle Java ME SDK distribution. For example, C:\Java_ME_platform_SDK_3.4.

  2. Change to the \bin directory and double click on update-center.exe to launch the Oracle Java ME SDK Update Center.

  3. Click on the Available and Updates tabs to find Samples (or to find other Oracle Java ME SDK software updates, such as new plugins.)

  4. Select the Samples or updates you want to install and click Add.

Using Sample Applications in the Emulator

The Oracle Java ME SDK platform comes with a number of sample applications. The following four demos best illustrate embedded features when run in Oracle Java ME SDK:


Note:

With the exception of the I2CDemo, the sample projects provided with the Oracle Java ME SDK release can be run on the emulator or on a real device.


Starting Sample Applications

There are two ways to start sample applications in Oracle Java ME SDK:

  • From the IMPNGDevice1 emulator:

    1. Select Application --> Run IMlet Suite

    2. Fill in the Run IMlet Suite dialog box and provide the Path or URL for the IMlet Suite, as shown in Figure A-1.

      Figure A-1 The Run IMlet Suite Dialog Box

      Description of Figure A-1 follows
      Description of "Figure A-1 The Run IMlet Suite Dialog Box"

  • From the Windows command line. Enter the following:

    emulator.exe -Xdevice:IMPNGDevice1 -Xdescriptor:C:\Java_ME_platform_SDK_3.4\apps\sample\<sample_demo_folder>\<sample_demo_name>.jad

For the four demos described in this chapter, all but GPIODemo can be started using both of the ways shown here.

The GPIODemo Sample Application

The GPIODemo can be run on the Oracle Java ME SDK emulator, IMPNGDevice1:

  1. Launch the External Events Generator by selecting Tools > External Events Generator or clicking on the External Events Generator icon.

  2. Click the GPIO tab. This displays the GPIO screen, as shown in Figure A-2.

    Figure A-2 The External Events Generator GPIO Tab

    Description of Figure A-2 follows
    Description of "Figure A-2 The External Events Generator GPIO Tab"

    The External Events Generator GPIO tab approximates actions on a device. Each button is a toggle that turns an LED on and off, changing the value of the corresponding Pin from High to Low, or Low to High.

    When a button is clicked, information is written to the IMPNGDevice1 GPIO Pins tab. Changes in the value of a Button can be seen in the Output and Value columns for Buttons 1, 2, and 3, as shown in Figure A-3.

  3. Click each button to change the value in the Output column of the GPIO Pins tab, in the IMPNGDevice1.

Figure A-3 The GPIO Pins Tab

Description of Figure A-3 follows
Description of "Figure A-3 The GPIO Pins Tab"

Notice the following about Buttons 1, 2, and 3 in the IMPNGDevice1 GPIO Pins tab:

  • Button 1 corresponds to Hardware Port Number 0 and Hardware Pin Number 0. Button 1 has a Rising Edge Trigger.

  • Button 2 corresponds to Hardware Port Number 2 and Hardware Pin Number 13. Button 2 has a Falling Edge Trigger.

  • Button 3 corresponds to Hardware Port Number 6 and Hardware Pin Number 15. Button 3 has a Falling Edge Trigger.

    For more information on Rising and Falling Edge Triggers, see "The Pulse Counter Tab."

The I2CDemo Sample Application

This demo is designed to work with the IMP-NG runtime for Windows. It has no user interaction.

To launch the I2C demo, click the I2C tab in IMPNGDevice1.

This demo acquires a slave named I2C_JOYSTICK, writes data to the slave, and retrieves it. The demo is successful if the Sent Data and Received Data match.

The NetworkDemoIMPNG Sample Application

The NetworkDemoIMPNG demo can be configured as a server or as a client by editing the application descriptor. You launch two instances of this demo, the first one acts as a server and the second one acts as a client. The client instance attempts to connect to the server instance and if the connection is successful they exchange a message.

  1. Create two instance projects of the NetworkDemoIMPNG sample project.

  2. Right click the first project and select Properties.

  3. In the Platform category choose the device IMPNGDevice1. In the Application Description category set the value of the following property:

    Oracle-Demo-Network-Mode:Server

  4. Click OK.

  5. Launch the first project. It opens on the emulator IMPNGDevice1 and waits for a connection. You should see messages like the following:

  6. Right click the second project and select Properties.

  7. In the Platform category choose the device IMPNGDevice2. In the Application Description category set the value of the following property:

    Oracle-Demo-Network-Mode:Client

  8. Click OK.

  9. Launch the second project. It opens on the emulator IMPNGDevice2.

  10. The client attempts to connect to the server. If successful, you see the following in the output tab of the first project (the server):

    Waiting for connection on port 500
    [AMS-TRACE] MIDlet:NetworkDemoIMPNG status=2
    [AMS-TRACE] MIDlet:NetworkDemoIMPNG status=1
    Connection accepted
    Message received - Client messages
    

    The output of the second project (the client) shows the following:

    [AMS-TRACE] MIDlet:NetworkDemoIMPNG status=2
    [AMS-TRACE] MIDlet:NetworkDemoIMPNG status=1
    Connected to server localhost on port 500
    Message received - Server string
    

The PDAPDemoIMPNG Sample Application

Follow these steps to run the PDADemoIMPNG demo on the IMPNGDevice1 emulator:

  1. Create test files and directories inside the emulator's file system:

    Documents and Settings\<user>\javame-sdk\<version>\work\IMPNGDevice1\appdb\filesystem\root1

  2. Right click the project and select Properties. In the Platform category choose the device IMPNGDevice1 and click OK.

  3. Launch the project. It runs on IMPNGDevice1.

  4. On the emulator menu, select Tools > File Connection to see a list of mounted file systems.

    Figure A-5 The Manage File System Window

    Description of Figure A-5 follows
    Description of "Figure A-5 The Manage File System Window"

  5. Open a terminal emulator and create a raw connection to localhost on port 5001. For example:

    telnet localhost 5001


    Note:

    The Telnet negotiation mode must be set to Passive. The negotiation mode can be set inside a Telnet client application (for example, PuTTY), by choosing Category > Connection > Telnet > Passive.


    A command line opens where you can browse the emulator's file system. You can use the following commands:

    • cd <dir_name> - Change directory

    • ls - List information about the files for the current directory

    • new file <file_name> - Create a new file

    • new dir <directory_name> - Create a new directory

    • prop <file_name> - Show properties of a file

    • rm <file_name> - Remove the file

    • view <file_name> - View a file's content

The Light Tracker Sample Application

The Light Tracker sample application is aimed at showing off funtionality on a embedded device, such as the Keil MCBSTM32F200 reference platform.

In this demo, a certain number of LEDs are turned on and turned off on the reference board, in a sequence that you can control. It makes use of the Device Access API and a GPIO Port to demonstrate its functionality. It requires connection of an ADC channel to an on-board potentiometer.

For more information on the setup of the Light Tracker sample application, see the LightTrackDemo readme.txt file, in the location where you have installed the Oracle Java ME SDK sample applications. For example:

C:\Documents and Settings\username\Java_ME_SDK\samples\LightTrackDemo

For more information on the Keil MCBSTM32F200 platform, see the Oracle Java ME Embedded Getting Started Guide for the Reference Platform (Keil).

The System Controller Sample Application

The System Controller sample application is aimed at showing off functionality on a embedded device, such as the Keil MCBSTM32F200 reference platform.

The purpose of this demo is to control the lifecycle of IMlets on the reference platform. It makes use of the following functionalities:

For more information on the setup of the System Controller sample application, see the SystemControllerDemo readme.txt file, in the location where you have installed the Oracle Java ME SDK sample applications. For example:

C:\Documents and Settings\username\Java_ME_SDK\samples\SystemControllerDemo

For more information on the Keil MCBSTM32F200 platform, see the Oracle Java ME Embedded Getting Started Guide for the Reference Platform (Keil).