Oracle® Java ME Embedded Getting Started Guide for the Windows Platform Release 8 EA 2 for NetBeans on Windows E48511-01 |
|
Previous |
Next |
Beta Draft: 2014-02-15
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. |
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:
Download the sample applications file from the Oracle Technology Network (OTN) to your machine.
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
Unzip the sample applications file. This displays a second zip file, com.oracle.javame.sdk.sample.applications.zip
.
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
Change to the /apps directory. You see the following directories listed, one for each sample application:
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:
Select Tools > JavaME > Device Selector to display the Device Selector in NetBeans 8.0 Beta, as shown in Figure 6-1.
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
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.
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.
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).
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.
Run GPIO demo on the EmbeddedDevice1 emulator.
Click the GPIO Pins tab. This view approximates the device actions.
Click the Tools menu and select External Events Generator to open the External Events Generator, and click the GPIO tab.
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.
This demo is designed to work with the Oracle Java ME SDK 8 EA 2. It has no user interaction.
Run the I2C demo on the EmbeddedDevice1 emulator.
Click the I2C tab.
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
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.
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.
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 Description category set the value of the following property:
Oracle-Demo-Network-Mode:Server
Click OK.
Launch 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 Description category set the value of the following property:
Oracle-Demo-Network-Mode:Client
Click OK.
Launch the second project. It opens on the emulator EmbeddedDevice2
.
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
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. |
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.
Launch the first project (the server). It runs on the emulator and waits for a connection.
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.
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
This demo is a version of the PDAPDemo file browser.
Follow these steps to run the demo on the EmbeddedDevice1
emulator:
Create test files and directories inside the emulator's file system:
\
username\javame-sdk\8.0_ea\work\EmbeddedDevice1\appdb\filesystem\root1
Load the project in the Package window.
In the Platform category, select the device EmbeddedDevice1 and click OK.
In the Device Selector window, right-click an EmbeddedDevice1 emulator.
Select Run Project > PDAPDemo from the context menu.
Launch the project.
On the EmbeddedDevice1 emulator, click 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 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
- 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
Follow these steps to run the demo on the reference board:
Right-click the project and select Properties. In the Platform category, select the device EmbeddedExternalDevice1 and click OK.
Launch 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 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.
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).
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).
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 may be launched 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.