Oracle® Java ME Embedded Getting Started Guide for the Windows Platform Release 3.3 E35132-02 |
|
![]() Previous |
![]() Next |
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:
In the emulator's External Events Generator
In the Windows command line console
Sample applications are available in two ways:
As part of the Oracle Java ME SDK Plugins for each IDE (that is, for NetBeans and Eclipse)
By downloading from the Oracle Java ME SDK Update Center
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. |
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:
Go to the location where you have installed the Oracle Java ME SDK distribution. For example, C:\Java_ME_platform_SDK_3.3
.
Change to the \bin
directory and double click on update-center.exe
to launch the Oracle Java ME SDK Update Center, as shown in Figure A-1.
Figure A-1 The Java ME SDK Update Center Window
Click on the Available and Updates tabs to find Samples (or to find other Oracle Java ME SDK software updates, such as new plugins.)
Select the Samples or updates you want to install and click Add.
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:
GPIODemo
I2CDemo
NetworkDemoIMPNG
PDAPDemoIMPNG
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. |
There are two ways to start sample applications in Oracle Java ME SDK:
From the IMPNGDevice1 emulator:
Select Application --> Run IMlet Suite
Fill in the Run IMlet Suite dialog box and provide the Path or URL for the IMlet Suite, as shown in Figure A-2.
Figure A-2 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.3\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 can be run on the Oracle Java ME SDK emulator, IMPNGDevice1:
Launch the External Events Generator by selecting Tools > External Events Generator or clicking on the External Events Generator icon.
Click the GPIO tab. This displays the GPIO screen, as shown in Figure A-3.
Figure A-3 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-4.
Click each button to change the value in the Output column of the GPIO Pins tab, in the IMPNGDevice1.
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."
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 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.
Create two instance projects of the NetworkDemoIMPNG sample project.
Right click the first project and select Properties.
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
Click OK.
Launch the first project. It opens on the emulator IMPNGDevice1 and waits for a connection. You should see messages like the following:
Right click the second project and select Properties.
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
Click OK.
Launch the second project. It opens on the emulator IMPNGDevice2.
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
Follow these steps to run the PDADemoIMPNG demo on the IMPNGDevice1 emulator:
Create test files and directories inside the emulator's file system:
Documents and Settings\
<user>\javame-sdk\
<version>\work\
IMPNGDevice1
\appdb\filesystem\root1
Right click the project and select Properties. In the Platform category choose the device IMPNGDevice1 and click OK.
Launch the project. It runs on IMPNGDevice1.
On the emulator menu, select Tools > File Connection to see a list of mounted file systems.
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 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 is aimed at showing off funtionality 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:
Multitasking Virtual Machine (MVM)
IMlet auto-start
Application Management System (AMS) API
Logging API
Device Access API
General Purpose Input/Output (GPIO)
Watchdog timer
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).