Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 8 for Windows
E50624-01
  Go To Table Of Contents
Contents

Previous
Previous
 
Next
Next
 

22 Using Sample Applications

The Oracle Java ME SDK 8 sample applications introduce you to the emulator's API features and the Oracle Java ME SDK 8 features, tools, and utilities that support the various APIs.


Note:

Before using the Oracle Java ME SDK 8 sample applications, carefully read Appendix B, "Installation and Runtime Security Guidelines." Some demonstrations use network access and open ports, and do not include protection against malicious intrusion. If you run the sample projects, ensure that your environment is secure.


Installing Sample Applications

Sample applications are installed using an Oracle Java ME SDK 8 ZIP file that has the following name format: jmesdk-8_0-samples-<build_number>-<date>.zip. The default location for installing the sample applications is in the Oracle Java ME SDK 8 installation directory.

To install sample applications:

  1. Download the sample applications file from the Oracle Technology Network (OTN).

  2. Move the sample applications file to the Oracle Java ME SDK 8 installation directory. By default, it is C:\Java_ME_platform_SDK_8.0.

  3. Extract the sample applications file and the file contained inside (com.oracle.javame.sdk.sample.applications.zip) to the apps directory.

  4. Ensure that the following subdirectories are available in the apps directory:

    • DataCollectionDemo

    • GPIODemo

    • I2CDemo

    • LightTrackDemo

    • NetworkDemo

    • PDAPDemo

    • SystemControllerDemo

Configuring the Web Browser and Proxy Settings

If you are behind a firewall, you can configure the sample applications to use proxy server settings that you define.

The sample application proxy server settings typically match the proxy server settings used in your web browser. To manually set the proxy server settings for your sample applications, do the following:

  1. In NetBeans IDE 8.0, open the Tools menu, select JavaME, and then Device Selector.

  2. Right-click CLDC, Oracle Java ME SDK 8.0 and select Properties.

  3. Specify the HTTP Proxy Settings, HTTP Proxy Host, and HTTP Proxy Port fields to match your network and browser settings.

Running Sample Applications

This section describes how to use sample applications created specifically for Oracle Java ME SDK 8. Because these sample applications are headless, you must observe the application status in the emulator's External Events Generator, in the Output window, or in the console window if you execute the demo straight from the command line.

Running the DataCollectionDemo

The DataCollectionDemo demonstrates the following functionality:

  • Multiple virtual machines (MVM)

  • Inter-IMlet communication using local datagrams

  • Device I/O API pulse counter

  • Device I/O API serial peripheral interface

  • Logging API

In the DataCollectionDemo, several data collector IMlets read data from peripheral devices using the Device I/O API and send the data to a data processor.

For more information about the setup and behavior of the DataCollectionDemo, see the readme.txt file, under apps\DataCollectionDemo in the Java ME SDK installation directory.

For more information about the Qualcomm IoE platform, see Oracle Java ME Embedded Getting Started Guide for the Reference Platform (Qualcomm IoE).

Running the GPIODemo

The GPIODemo can run on an emulator. The implementations are different, because the emulator uses the External Events Generator, and the external device supports direct interaction.

To run GPIODemo on the emulator:

  1. Run GPIODemo on the EmbeddedDevice1 emulator.

  2. Click the GPIO Pins tab. This view approximates the device actions.

  3. Open the Tools menu and select External Events Generator. Open the GPIO tab.

  4. Click BUTTON 1 in the External Events Generator to toggle the state of the pin named BUTTON 1 in the EmbeddedDevice1 emulator. If the button value in the External Events Generator is changed to High, then the button value in the EmbeddedDevice1 emulator is also changed to High.

Running the I2CDemo

The I2CDemo is designed to work with Oracle Java ME SDK 8. It has no user interaction.

To run I2CDemo on the emulator:

  1. Run I2CDemo on the EmbeddedDevice1 emulator.

  2. Click the I2C tab.

  3. Run I2CDemo.jad located under apps\I2CDemo in the Java ME SDK installation directory.

  4. The I2CDemo acquires a slave named I2C_Joystick, writes data to the slave, and retrieves it. The I2CDemo is successful if the Sent Data and Received Data match.

Running the NetworkDemo

You can configure the NetworkDemo as a server or as a client by editing the application descriptor. You start two instances of NetworkDemo; 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.

To run NetworkDemo on the emulator:

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

  2. Right-click the first project and select Properties.

  3. In the Platform category, select the device EmbeddedDevice1. In the Application Descriptor category, set the value of the following property:

    Oracle-Demo-Network-Mode:Server
    
  4. Click OK.

  5. Start the first project. It opens on the emulator EmbeddedDevice1 and waits for a connection.

  6. Right-click the second project and select Properties.

  7. In the Platform category, select the device EmbeddedDevice2. In the Application Descriptor category, set the value of the following property:

     Oracle-Demo-Network-Mode:Client
    
  8. Click OK.

  9. Start the second project. It opens on the emulator EmbeddedDevice2.

  10. The client attempts to connect to the server. If successful, the following is displayed in the output for the first project (the server):

    Waiting for connection on port 5000
    Connection accepted
    Message received - Client messages
    

    The following is displayed in the output of the second project (the client):

    Connected to server localhost on port 5000
    Message received - Server string
    

Running the NetworkDemo on the Reference Board

You can run one of the instance projects on the board and the other in one of the emulators.


Note:

Applications that are run on an embedded platform, such as the Qualcomm IoE or Raspberry Pi, must be signed. For more information, see the Oracle Java ME SDK 8 Getting Started Guide for your embedded platform.


To run the client on the board and the server in one of the emulators:

  1. Right-click the first project (the server) and select Properties. In the Platform category, select the device EmbeddedDevice1 (the emulator). In the Application Descriptor category, set the value of the property Oracle-Demo-Network-Mode to Server and click OK.

  2. Start the first project (the server). It runs on the emulator and waits for a connection.

  3. Right-click the second project (the client) and select Properties. In the Platform category, select the device EmbeddedExternalDevice1 (the board). In the Application Descriptor category, set the value of the property Oracle-Demo-Network-Mode to Client and the value of the property Oracle-Demo-Network-Address to the IP address of the computer where NetBeans IDE 8.0 is running and click OK.

  4. Start the second project (the client). It runs on the board and attempts to connect to the server. If successful, the following is displayed in the output tab of the first project (the server):

    Connection accepted
    Message received - Client messages
    

    The following is displayed in the TCP log of the board (the client):

    Connected to server 10.0.0.10 on port 5000
    Message received - Server String
    

Running the PDAPDemo

To run PDAPDemo on the emulator:

  1. Create test files and directories inside the emulator's file system. The file system is located in the Java ME SDK configuration directory. For example, for EmbeddedDevice1, the file system is located under userdir\javame-sdk\8.0\work\EmbeddedDevice1\appdb\filesystem\root1

  2. Open the project in NetBeans IDE 8.0, right-click the project and select Properties.

  3. In the Platform category, select the device EmbeddedDevice1 and click OK.

  4. In the Device Selector window, right-click an EmbeddedDevice1 emulator, select Run Project and then PDAPDemo.

  5. Start the project.

  6. On the EmbeddedDevice1 emulator, open the Tools menu and select Manage File System to see a list of mounted file systems.

  7. Open a terminal emulator and create a Telnet connection to localhost on port 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 selecting Category, then Connection, then Telnet, and then Passive.


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

    • cd: Change directory

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

    • new: Create a file or directory

    • prop: Show properties of a file

    • rm: Remove a file

    • view: View a file's content

Running the PDAPDemo on the Reference Board

To run PDAPDemo on the reference board:

  1. Right-click the project and select Properties. In the Platform category, select the device EmbeddedExternalDevice1 and click OK.

  2. Start the project. It runs on the reference board.

  3. Open a terminal emulator and create a raw connection to the IP address of the board on port 5001.

  4. The command line that opens is the same as the one you use when you run the PDAPDemo on the emulator.

The file system of the demo is stored in the java directory on the SD card. In that directory, there are a subdirectories that are named using the number identifier that the AMS assigns to an IMlet during its installation.

Running the LightTrackDemo

The LightTrackerDemo is specifically aimed at demonstrating functionality on an embedded device.

In the LightTrackerDemo, a certain number of LEDs are turned on and turned off on the board, in a sequence that you can control. It makes use of the Device I/O API and the GPIO port to demonstrate its functionality. It requires connection of an ADC channel to an on-board potentiometer.

For more information about the setup and behavior of the Light Tracker demo, see the readme.txt file located under apps\LightTrackDemo in the Java ME SDK installation directory.

Running the SystemControllerDemo

The SystemControllerDemo is specifically aimed at showing off functionality on an embedded device, such as the Qualcomm IoE reference platform.

The purpose of the SystemControllerDemo is to control the life cycle of IMlets on the reference platform. It makes use of the following functionalities:

  • Multitasking Virtual Machine (MVM)

  • IMlet auto-start

  • Application Management System (AMS) API

  • Logging API

  • General Purpose Input/Output (GPIO)

  • Watchdog timer

For more information about the setup and behavior of the System Controller demo, see the readme.txt file located under apps\SystemControllerDemo in the Java ME SDK installation directory.

For more information about the Qualcomm IoE platform, see Oracle Java ME Embedded Getting Started Guide for the Reference Platform (Qualcomm IoE).

Troubleshooting

Sometimes a sample application does not run successfully. Often, the problem is your environment.