Oracle® Java Micro Edition Software Development Kit Developer's Guide Release 8 for Windows E50624-01 |
|
Previous |
Next |
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. |
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:
Download the sample applications file from the Oracle Technology Network (OTN).
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
.
Extract the sample applications file and the file contained inside (com.oracle.javame.sdk.sample.applications.zip
) to the apps
directory.
Ensure that the following subdirectories are available in the apps
directory:
DataCollectionDemo
GPIODemo
I2CDemo
LightTrackDemo
NetworkDemo
PDAPDemo
SystemControllerDemo
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:
In NetBeans IDE 8.0, open the Tools menu, select JavaME, and then Device Selector.
Right-click CLDC, Oracle Java ME SDK 8.0 and select Properties.
Specify the HTTP Proxy Settings, HTTP Proxy Host, and HTTP Proxy Port fields to match your network and browser settings.
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.
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).
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:
Run GPIODemo
on the EmbeddedDevice1 emulator.
Click the GPIO Pins tab. This view approximates the device actions.
Open the Tools menu and select External Events Generator. Open the GPIO tab.
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.
The I2CDemo
is designed to work with Oracle Java ME SDK 8. It has no user interaction.
To run I2CDemo
on the emulator:
Run I2CDemo
on the EmbeddedDevice1 emulator.
Click the I2C tab.
Run I2CDemo.jad
located under apps\I2CDemo
in the Java ME SDK installation directory.
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.
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:
Create two instance projects of the NetworkDemo
sample project.
Right-click the first project and select Properties.
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
Click OK.
Start the first project. It opens on the emulator EmbeddedDevice1
and waits for a connection.
Right-click the second project and select Properties.
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
Click OK.
Start the second project. It opens on the emulator EmbeddedDevice2
.
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
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:
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.
Start the first project (the server). It runs on the emulator and waits for a connection.
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.
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
To run PDAPDemo
on the emulator:
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
Open the project in NetBeans IDE 8.0, right-click the project and select Properties.
In the Platform category, select the device EmbeddedDevice1 and click OK.
In the Device Selector window, right-click an EmbeddedDevice1 emulator, select Run Project and then PDAPDemo.
Start the project.
On the EmbeddedDevice1 emulator, open the Tools menu and select Manage File System to see a list of mounted file systems.
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. |
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
To run PDAPDemo
on the reference board:
Right-click the project and select Properties. In the Platform category, select the device EmbeddedExternalDevice1 and click OK.
Start the project. It runs on the reference board.
Open a terminal emulator and create a raw connection to the IP address of the board on port 5001.
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.
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.
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).
Sometimes a sample application does not run successfully. Often, the problem is your environment.
Some demonstrations require specific setup and instructions. For example, if a sample uses web services and you are behind a firewall, you must configure the emulator's proxy server settings. See "Configuring the Web Browser and Proxy Settings."
Because sample programs can be started remotely, virus checking software can sometimes prevent them from running. In the console, you see warnings that the emulator cannot connect.
Consider configuring your antivirus software to allow access to sample application directories and components.