Skip Headers
Oracle® Java ME Embedded Getting Started Guide for the Windows Platform
Release 8 EA 2 for NetBeans on Windows
E48511-01
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

Beta Draft: 2014-02-15

6 Using Sample Applications

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


Note:

Before using the Oracle Java ME SDK 8 EA 2 sample applications, see "Installation and Runtime Security Guidelines in Appendix B, "Installation and Runtime Security Guidelines." 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.


Installing Sample Applications

Sample applications are installed using an Oracle Java ME SDK 8 EA 2 zip file, jmesdk-8_0-ea2-samples-<build_number>-<date>.zip. The default location for installing the sample applications is in the location where you have installed Oracle Java ME SDK 8 EA 2. Do the following:

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

  2. Move the sample applications file into the location where you have installed Oracle Java ME SDK 8 EA 2. For example:

    C:\Java_ME_platform_SDK_8.0_EA

  3. Unzip the sample applications file. This displays a second zip file, com.oracle.javame.sdk.sample.applications.zip.

  4. Unzip the com.oracle.javame.sdk.sample.applications.zip file. This creates the /apps directory, as shown here:

    C:\Java_ME_platform_SDK_8.0_EA\apps

  5. Change to the /apps directory. You see the following directories listed, one for each sample application:

    • 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. Select Tools > JavaME > Device Selector to display the Device Selector in NetBeans 8.0 Beta, as shown in Figure 6-1.

    Figure 6-1 The Device Selector

    Description of Figure 6-1 follows
    Description of "Figure 6-1 The Device Selector"

  2. Right click on CLDC, Oracle Java(TM) ME SDK 8.0 EA and select Properties from the pop-up menu, to display the Device Selector properties screen, as shown in Figure 6-2.

    Figure 6-2 The Device Selector Properties Screen

    Description of Figure 6-2 follows
    Description of "Figure 6-2 The Device Selector Properties Screen"

  3. To configure the Device Selector Properties proxy settings, fill in 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 EA 2. Because these sample applications are headless, the only user interface is to observe application status in the emulator's External Events Generator, in the Output window, or in the console window, if you execute the demo from the command line.

Running the Data Collection Demo

The Data Collection demo demonstrates the following functionality:

  • Multiple virtual machines (MVM)

  • Inter-IMlet communication using local datagrams

  • Device Access API pulse counter

  • Device Access API serial peripheral interface

  • Logging API

In this demo, several data collector IMlets read data from peripheral devices using the Device Access API and send the data to a data processor.

For more information on the setup and behavior of the Data Collection demo, see the DataCollectionDemo readme.txt file, in the location where you have installed the Oracle Java ME SDK 8 EA 2 sample applications. For example:

C:\Java_ME_platform_SDK_8.0_EA\apps\DataCollectionDemo

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

Running the GPIO Demo

This demo can be run on an emulator. The implementations are different, as the emulator uses the external events generator, and the external device supports direct interaction.

Running the GPIODemo on the Emulator

  1. Run GPIO demo on the EmbeddedDevice1 emulator.

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

  3. Click the Tools menu and select External Events Generator to open the External Events Generator, and click the GPIO tab.

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

Changing the state of a GPIO button is a toggle, which allows you to switch the pin value from Low to High, and back again.

Running the I2C Demo

This demo is designed to work with the Oracle Java ME SDK 8 EA 2. It has no user interaction.

Running the I2C Demo on the Emulator

  1. Run the I2C demo on the EmbeddedDevice1 emulator.

  2. Click the I2C tab.

  3. Using the Windows 7 user interface, navigate to the location where you have installed the I2C demo application. For example:

    C:\Java_ME_platform_SDK_8.0_EA\apps\I2CDemo

  4. Double-click on the I2CDemo.jad.

    The 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.

Running the Network Demo

You can configure this demo 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.

Running 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 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 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 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 EmbeddedDevice2.

  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 5000
    Connection accepted
    Message received - Client messages
    

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

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

Running NetworkDemo on the Reference Board

You can run one of the instance projects on the board and the other in one of the emulators. Follow these steps to run the client on the board and the server in one of the emulators:


Note:

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


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

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

  3. Right click on the second project (the client) and select Properties. In the Platform category select the device EmbeddedExternalDevice1 (the board). In the Application Description category set the value of the property Oracle-Demo-Network-Mode to Client and click OK.

    In the Application Descriptor category set the value of the property Oracle-Demo-Network-Address to the IP address of the computer where NetBeans 8.0 Beta is running and click OK.

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

    Connection accepted
    Message received - Client messages
    

    The TCP log of the board (the client) shows the following:

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

Running the PDAP Demo

This demo is a version of the PDAPDemo file browser.

Running the PDAPDemo on the Emulator

Follow these steps to run the demo on the EmbeddedDevice1 emulator:

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

    \username\javame-sdk\8.0_ea\work\EmbeddedDevice1\appdb\filesystem\root1

  2. Load the project in the Package window.

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

  4. In the Device Selector window, right-click an EmbeddedDevice1 emulator.

  5. Select Run Project > PDAPDemo from the context menu.

  6. Launch the project.

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

  8. 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 choosing Category --> Connection --> Telnet --> Passive.


  9. 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 new file or directory

    • prop - show properties of a file

    • rm - remove the file

    • view -View a file's content

Running PDAPDemo on the Reference Board

Follow these steps to run the demo on the reference board:

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

  2. Launch 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 demo on the emulator.

The file system of the demo is stored in the directory java/IMletID inside the SD card, where IMletID is a number that the AMS assigns to an IMlet during its installation.

Running the Light Tracker Demo

The Light Tracker demo is specifically aimed at showing off functionality on a embedded device, such as the Qualcomm Orion IoE reference platform.

In this demo, 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 Access API and the GPIO Port to demonstrate its functionality. It requires connection of an ADC channel to an on-board potentiometer.

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

C:\Java_ME_platform_SDK_8.0_EA\apps\LightTrackDemo

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

Running the System Controller Demo

The System Controller demo is specifically aimed at showing off functionality on a embedded device, such as the Qualcomm Orion IoE 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:

  • Multitasking Virtual Machine (MVM)

  • IMlet auto-start

  • Application Management System (AMS) API

  • Logging API

  • General Purpose Input/Output (GPIO)

  • Watchdog timer

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

C:\Java_ME_platform_SDK_8.0_EA\apps\SystemControllerDemo

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

Troubleshooting

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