Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 3.2 for Eclipse on Windows
E37550-02
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

3 Using Sample Projects

The Oracle Java ME SDK sample projects introduce you to the emulator's API features and the SDK features, tools, and utilities that support the various APIs. These features can help you customize the sample projects or create applications of your own.


Note:

As mentioned in Section 1.2, "Java ME SDK Update Center" the demos are delivered and installed separately. Before using the demos, please see the "Installation and Runtime Security Guidelines" in the Oracle Java Micro Edition Software Development Kit Release Notes. Some demos use network access and open ports. Because the sample code does not include protection against malicious intrusion, you must ensure your environment is secure should you choose to run the sample projects.


For instructions on running projects, see the following topics:

3.1 Creating a Sample Project

Sample applications are installed in a separate Eclipse plugin. Do not run or edit these projects directly. You create a new project that is an instance of the sample project.

The default location for Oracle Java ME SDK projects is the default Eclipse project directory. Each project has a src directory that contains Java programming language source code. For example, the default location of the source code for the SMS sender MIDlet (example.sms.SMSSend) in WMADemo resides in the following location:

EclipseWorkspace\WMADemo\src\example\sms\SMSSend.java

  1. Go to File > New > Project and in the Categories window select Examples > Java ME SDK 3.2 and click on Java ME Sample Applications. Click Next. In the next screen choose one of the samples and click Finish.

  2. If prompted, choose an emulator platform and a device. Note, changing the device affects the possible device profiles, so you might need to explicitly select a profile. Click OK.

    The project is added to the Package Explorer window.


    Note:

    If you can't see the Packager Explorer window choose Window > Show View > Package Explorer. To see console output, select Window > Show View > Console.


3.2 Running a Project

Create your own project, or instantiate one of the sample projects provided with the SDK as described in Section 3.1, "Creating a Sample Project."

  1. Use one of these methods to run a project.

    • Select a project and click the green Run button in the toolbar.

    • Right-click a project and select Run As > Emulated Java ME JAD from the context menu.

    • To run a project on a different device, or to change the execution mode, choose the device in the Device Selector window (Window > Show View > Other > Java ME SDK Tools > Device Selector).

      Right-click on a device and select Run Project from the context menu. Pull right to see a listing of open projects.

    The device emulator window opens with the demo application running. If the demo is a MIDlet suite you might have to choose a MIDlet to launch.

  2. As the sample project runs, soft keys might be enabled below the screen on the left or right side.

    You use soft keys to install or launch an application, open a menu, exit, or perform some other action. Some demos include these instructions in the application.

    For instructions on running samples, see Table 3-1.

  3. When you are finished viewing an application, go to the emulator's Application menu and select Exit to close the emulator and stop the execution of the project's build script.

    When the emulator is launched, it runs as an independent process. Stopping the application from Eclipse does not close the emulator instance.

    Likewise, closing the Eclipse IDE does not affect the emulator instance. In the emulator, select Application > Exit or press the emulator's exit button (the X) on the upper right to ensure that both the emulator process and the project build process close.

3.3 Troubleshooting

Sometimes even a "known good" application, such as a sample project, does not run successfully. The problem is usually your environment.

3.4 Sample Project Overview

The Oracle Java ME SDK includes demonstration applications that highlight some technologies and APIs that are supported by the emulator.

Most demonstration applications are simple to run. Section 3.2, "Running a Project" contains instructions for running most demonstrations. Sample projects usually have some additional operation instructions.

Table 3-1 lists all the MIDP/CLDC demonstration applications that are included in this release.

Table 3-1 MIDP/CLDC Sample Projects

Sample Optional Package Description Instructions

Advanced Multimedia Supplements

JSR 234

Demonstrates 3D audio, reverberation, image processing, and camera control.

Section 3.6.1, "Running the AdvancedMultimediaSupplements Sample Project"


AudioDemo

MMAPI 1.1

Demonstrates audio capabilities, including mixing and playing audio with an animation.

Section 16.4, "Running AudioDemo"


BluetoothDemo

JSR 82

Demonstrates device discovery and data exchange using Bluetooth.

Section 15.2, "Running the Bluetooth Demo"


CHAPIDemo

JSR 211

A content viewer that also uses MediaHandler.

Chapter 21, "JSR 211: Content Handler API (CHAPI)"


CityGuide

JSR 179

A city map that displays landmarks based on the current location.

Section 18.2, "Running the CityGuide Sample Project"


Contactless

JSR 257

Emulates detection of RFID tags.

Section 25.1, "Using ContactlessDemo"


Demo3D

JSR 184

Contains MIDlets that demonstrate how to use 3D graphics, both immediate mode and retained mode.

Section 20.4, "Running Demo3D Samples"


Demos

MIDP 2.0

Includes various examples: animation, color, networking, finance, and others.

Section 3.6.2, "Running the Demos Sample Project"


FPDemo

CLDC 1.1

Simple floating point calculator.

Section 3.6.3, "Running FPDemo"


Games

MIDP 2.0

Includes TilePuzzle, WormGame, and PushPuzzle.

Section 3.6.4, "Running Games".

LWUITBrowser

N/A

Demonstrates LWUIT features.

Chapter 9, "Lightweight UI Toolkit"


LWUITDemo

N/A

Demonstrates LWUIT features.

Chapter 9, "Lightweight UI Toolkit"


LWUITIODemo

N/A

Demonstrates LWUIT features.

Chapter 9, "Lightweight UI Toolkit"


LWUITMakeover

N/A

Demonstrates LWUIT features.

Chapter 9, "Lightweight UI Toolkit"


LWUITSpeed

N/A

Demonstrates LWUIT features.

Chapter 9, "Lightweight UI Toolkit"


LWUITTimeZone

N/A

Demonstrates LWUIT features.

Chapter 9, "Lightweight UI Toolkit"


LWUITTipster

N/A

Demonstrates LWUIT features.

Chapter 9, "Lightweight UI Toolkit"


MMAPIDemos

MMAPI

Demonstrates MMAPI features, including tone sequences, MIDI playback, sampled audio playback, and video.

Section 16.5, "Running MMAPIDemos"


Multimedia

MMAPI

Demonstrates different video playback formats.

Section 16.5.3, "Video"


NetworkDemo

MIDP 2.0

Demonstrates how to use datagrams and serial connections.

Section 3.6.5.1, "Socket Demo" and Section 3.6.5.2, "Datagram Demo"

ObexDemo

JSR 82

Demonstrates device discovery and data exchange using Bluetooth.

Section 15.3, "Running the OBEX Demo"


PDAPDemo

JSR 75

Demonstrates how to manipulate contacts, calendar items, and to-do items. Demonstrates accessing local files.

Section 14.3, "Running PDAPDemo"


PhotoAlbum

MIDP 2.0

Demonstrates a variety of image formats.

Section 3.6.6, "Running PhotoAlbum"


SATSADemos

JSR 177

Demonstrates communication with a smart card and other features of SATSA.

Section 17.4, "Running SATSADemos"


SATSAJCRMIDemo

JSR 177

Shows how to use the SATSA-Java Card Remote Invocation method.

Section 17.5, "Running SATSAJCRMIDemo"


Sensors

JSR 256

The SensorBrowser and Marbles game demonstrate sensor input.

Section 24.4, "SensorBrowser" and Section 24.5, "Marbles"

SVGContactList

JSR 226

Uses SVG to create a contact list displayed with different skins.

Section 22.2, "Running SVGContactList"


SVGDemo

JSR 226

Uses different SVG rendering techniques.

Section 22.1, "Running SVGDemo"


UIDemo

MIDP 2.0

Showcases the breadth of MIDP 2.0's user interface capabilities.

Section 3.6.7, "Running UIDemo"


WMADemo

WMA 2.0

Shows how to send and receive SMS, CBS, and MMS messages.

Section 19.2, "Running WMADemo"


XMLAPIDemo

JSR 280

Uses DOM and StAX APIs to create an XML sample and SAX, DOM and StAX APIs to parse the sample.

Follow the instructions the application provides.


3.5 Configuring the Web Browser and Proxy Settings

If you are behind a firewall you must configure the proxy server so that MIDP applications using web services can succeed.

The settings are typically the same as those you are using in your web browser. Select Window > Preferences > General > Network Connections and change the settings as appropriate.

3.6 Running MIDP and CLDC Sample Projects

This topic gathers MIDP and CLDC samples that are not discussed in separate chapters. This is the case when a sample uses many JSRs, or when a supported JSR does not have any special implementation details.

For other CLDC demos, see Table 3-1.

3.6.1 Running the AdvancedMultimediaSupplements Sample Project

This MIDlet suite demonstrates the power of JSR 234 Advanced Multimedia Supplements (AMMS). It consists of the following MIDlets:


Section 3.6.1.1, "Image Effects"
Section 3.6.1.2, "Music Effects"
Section 3.6.1.3, "Camera"
Section 3.6.1.4, "Moving Helicopter"

3.6.1.1 Image Effects

This MIDlet demonstrates standard image processing operations.

  • Launch the Image Effects MIDlet.

  • Choose input and output image formats, and press Done. The input image and output images are displayed simultaneously.

  • Choose an effect from the Menu and click the Done button to apply a transformation, effect or overlay. The source image is shown above and the processed image is shown below. Some items, Set Transforms, for example, can perform several operations in a single transaction.

    The menu options are as follows:

    • Reset - Set transforms, effects, and overlays to the initial state.

    • Monochrome Effects - Activate grayscale rendering.

    • Negative Effect -Reverse dark and light areas.

    • Set Formats - Select an input object type and an output image format.

    • Set Effect Order - Specify the order in which transforms, effects and overlays are applied.

    • Set Transforms - Change width and height scale, border, and rotation options.

    • Set Overlays - Specify the color and orientation of a color block overlay.

3.6.1.2 Music Effects

Demonstrates the advanced audio capabilities of the Advanced Multimedia Supplements. As an audio file loops continuously, you can adjust the volume, and reverberation settings.

3.6.1.3 Camera

This MIDlet demonstrates how the Advanced Multimedia Supplements provide control of a device's camera. The screen shows the viewfinder of the camera (simulated with a movie). You can use commands in the menu to change the camera settings and take and manage snapshots.

  • Zoom settings - digital and optical zoom settings 100-300 in increments of 20. Make a selection and press Back.

  • View gallery - View a list of the snapshots stored in: userhome\javame-sdk\3.2\work\device\appdb\filesystem\root1. Choose Display to see the snapshot. You have the option to delete the file from disk. If \root1 is empty use the Snapshot option to save images for the gallery.

  • Set flash mode - Off, AUTO, AUTO_WITH_REDEYEREDUCE, FORCE, FORCE_WITH_REDEYEREDUCE, FILLIN.

  • Change F_Stop number - 0, 400, 560, 800, 1600.

  • Choose exposure modes - Preset modes are auto, landscape, snow, beach, sunset, night, fireworks, portrait, backlight, spotlight, sports, text.

  • Disable/Enable shutter feedback.

  • Exit - Close this MIDlet and return to the initial window.

  • Snapshot setting - Set whether to display the snapshot on the screen or print it to a file. Snapshots are stored in:

    userhome\javame-sdk\3.2\work\emulator_name\appdb\filesystem\root1

3.6.1.4 Moving Helicopter

Simulates a helicopter (red dot) flying around a stationary observer (blue dot). Use headphones for best results. You can control the parameters of the simulation with the soft menu options: Volume, Location settings, Spectator orientation, and Distance Attenuation settings. After viewing menu options, press the close button (the X on the right) to return to the helicopter scenario.

With the Location settings be aware that supplying large values for the screen width or flight altitude means the helicopter might be out of range - that is, it flies off the screen and you might not be able to hear it.

For spectator orientation stereo headphones or speakers help detect the difference in position, assuming your volume and location settings put the helicopter in audible range. The same is true for the Distance Attenuation settings, which enable you to control the doppler effect.

3.6.2 Running the Demos Sample Project

This demo contains several MIDlets that highlight different MIDP features. Click or use the navigation keys to highlight a MIDlet, then choose the Launch soft key.

3.6.2.1 Colors

This application displays a large horizontal rectangle that runs the width of the screen. Below, ten small vertical rectangles span the screen. Finally, three horizontal color bars indicate values for blue, green, and red (RGB). Values are expressed as decimal (0-255) or hexadecimal (00-ff) based on the first menu selection.

  • To select a vertical bar to change, use the up navigation arrow to move to the color bars. Use the right navigation arrow to highlight a color bar. The large rectangle becomes the color of the selected bar.

  • Use the up or down selection arrows to choose the value to change (red, green, or blue). Use the left or right arrow keys to increase or decrease the selected value. The second menu item enables you to jump in increments of 4 (Fine) or 32 (coarse).

  • You can change the color on any or all of the vertical bars.

3.6.2.2 Properties

This MIDlet displays your system property values. The output is similar to the following values:

Free Memory = 2333444
Total Memory = 4194304
microedition.configuration = "CLDC-1.1"
microedition.profiles = "MIDP-2.1"
microedition.platform = "generic"
microedition.platform = "en-US"
microedition.platform = "IS08859_1"

3.6.2.3 Http

This test application uses an HTTP connection to request a web page. The request is issued with HTTP protocol GET or POST methods. If the HEAD method is used, the head properties are read from the request.

Preparing to Run the Demo

Before beginning, examine your settings as follows.

  • Right-click on Demos and select Properties.

    • Select the Running category.

    • Select Regular Execution.

    • Check Specify the Security Domain and select Maximum.

    • Click OK.

  • If you are using a proxy server, you must configure the emulator's proxy server settings as described in Section 3.5, "Configuring the Web Browser and Proxy Settings." The HTTP version must be 1.1.

  • If you are running antivirus software it might be necessary to create a rule that allows your MIDlet to permit connections to and from a specific web site. See Section 3.3, "Troubleshooting."

Running the Demo

Launch the Http MIDlet. To test, choose the Menu soft key and choose Get, Post, or Head to test the selected URL.

Http Test returns the information it obtains. If the information fills the screen use the down arrow to scroll to the end. The amount of information depends on the type of request and on the amount of META information the page provides. To provide body information or content, the page must declare CONTENT-LENGTH as described in RFC 2616.

Using Menu Options

Use the Menu soft key to choose an action. The Menu items vary depending on the screen you are viewing.

  • Choose Qwerty to set the input type. This activates a submenu with the options Qwerty, 123, Abc, Predict, and Symbols. This choice is present if you have the option to edit a URL (select Choose, then click the Add soft button).

  • Choose GET or press the Get soft key to retrieve data from the selected URI.

  • Choose POST to retrieve the post information from the server handling the selected page.

  • Choose HEAD to retrieve only the META information from the headers for the selected URI.

  • Select Choose to bring up the current list of web pages. You can chose a different page or add your own page to the list. To specify a new URL, choose the Add soft button. The screen displays http://. Type in the rest of the URL. If necessary select Qwerty on the menu and choose a different input method. Be sure to end with a slash (/). For example http://www.internetnews.com/. Press the OK soft button. The Http Test screen shows your new URL and prompts for an action.

3.6.2.4 FontTestlet

This MIDlet shows the various fonts available: Proportional, Regular, Regular Italic, Bold Plain, and Bold Italic. Choose 1 or 2 from the menu to toggle between the system font (sans serif) and the monospace font.

3.6.2.5 Stock

Like the Http demonstration, this sample uses an HTTP connection to obtain information. Use the same preparation steps as Section 3.6.2.3, "Http."

Run the Demos project and launch the Stock MIDlet.

By default, the screen displays an empty ticker bar at the bottom. The MIDlet home screen shows four applications: Stock Tracker, What If? Alerts, and Settings. You must add stock symbols before you can use the first three applications.

Add Stock Symbols to the Ticker

To add a stock symbol to the ticker, use the navigation arrows to select Settings.

Select Add Stock.

The display prompts you to enter a stock symbol. Type ORCL and select the Done soft key. The stock you added and its current value is now displayed in the ticker. Add a few more stock symbols, such as IBM and HPQ.

Change the Update Interval

By default the update interval is 15 minutes. Select Settings > Updates to change the interval. Use the navigation arrows to select one of Continuous, 15 minutes, 30 minutes, one hour, or three hours. Select the Done soft key.

Remove a Stock

Select Remove a Stock. You see a list of the stocks you have added. Use the navigation keys to select one or more stocks to remove. Choose the Done soft key.

Stock Tracker

Stock Tracker displays a list of the stocks you added and their current values. Click a stock to display additional information. For example, the last trade and the high and low values.

What If?

What If? is an application that asks for the original purchase price and the number of shares you own. It calculates your profit or loss based on the current price.

Select a stock symbol.

Enter the purchase price and the number of shares, then press Calc.

Alerts

This application sends you a notification when the price changes to a value you specify.

From the Stock Menu application home screen, select Alerts.

Select Add.

Choose a Stock. The screen prompts, "Alert me when a stock reaches". Enter an integer.

When an alert is created it is placed on the Current Alerts list. To remove an alert, press Remove and select the alert. Choose the Done soft key.

When the value is reached you hear a ring and receive a message. For example, Symbol has reached your price point of $value and is currently trading at $current_value. When the alert is triggered it disappears from the Current Alerts list.

3.6.2.6 Tickets

This demonstrates how an online ticket auction application might behave. Click Done to continue to the Welcome To Tickets page. The Choose a Band field displays BootWare & Friends by default, and an auction ticker runs at the bottom of the screen.

Choose a band from the dropdown menu. The available auction appears.

Select Make a Bid from the menu. Use the arrow keys to move from field to field. Fill out each field, then select the Next soft key. The application asks you to confirm your bid. Press the Submit button or use the arrow keys to highlight Submit then press the Submit soft key. You receive a Confirmation number. Click Bands to return to the Bands page.

Select set an alert, select Set an Alert from the soft Menu. In the bid field type in a value higher than the current bid and continue bidding as before. You can trigger the alert by making a bid that exceeds your alert value. Your settings determine how often the application checks for changes, so the alert may not sound for a few minutes.

To add a band to the Choose a Band dropdown list, select the Menu soft key and choose Add Bands. Type in a band name or a comma-delimited list of names and choose Save from the soft menu. After a confirmation message, choose Done and you are returned to the Welcome To Tickets page. The added band(s) are displayed at the end of the Choose a Band drop-down menu. If you don't see your bands, use the down arrow key to move to the bottom of the list.

Note, this is only a demonstration. To fully describe the band you must edit the following file:

src\example\auction\NewTicketAuction.java.

To remove a band, select the Menu soft key and Remove Bands. Check a box for one or more bands. Choose the Save soft key.

To display the current settings for ticker display, updates, alert volume, and date, select the Menu soft key and choose Show More Info. If desired, use the arrow keys and the select key to change these values. Choose the Save soft key.

3.6.2.7 ManyBalls

This MIDlet starts with one ball traveling the screen. Use the up and down arrows to accelerate or decelerate the ball speed (fps). Use the right or left arrows to increase or decrease the number of balls.

3.6.2.8 MiniColor

This MIDlet sets an RGB value. Use navigation keys to change color values.

Keyboard controls work as you would expect. First cursor up or down to highlight a color, and then use left and right keys to lower and raise the value of the selected color.

3.6.2.9 Chooser

The Chooser application uses a variety of controls to change text color, background color, and fonts.

  • Choose Menu > Text Color. Change the color as described for MiniColor and select the OK soft button.

  • Choose Menu > Background Color. Change the color as described for MiniColor and select the OK soft button.

  • Choose Menu > Fonts. You can change the font Face, Style, and Size.

    Cursor up and down to highlight a property item by item. The left and right keys jump between lists. Click select to choose the highlighted option. The chosen option's circle or square is filled with white.

    Click OK to display a sample formatted with your settings.

    Click Exit to return to the home screen.

3.6.2.10 HttpExample

This sample makes an HTTP communication. A popup confirms the transaction was successful.

3.6.2.11 HttpView

This application displays three predefined URLs.

Choose a URL, and press the soft buttons to cycle through Head, Headers, Requests, and Errors.

Alternatively, Use the menu options.

3.6.2.12 PushExample

This application simulates a feed. As soon as you connect, you receive and display a graphic. Select Done to continue.

3.6.3 Running FPDemo

FPDemo is a simple floating point calculator.

  1. Enter a number in the first field.

  2. To choose an operator, highlight the drop-down list and click to select. Cursor down to highlight an operator, then click to make a selection.

  3. Enter a second value.

  4. From the Menu, select Calc to calculate the result.

3.6.4 Running Games

This application features three games: TilePuzzle, WormGame, and PushPuzzle.

TilePuzzle. The desired result, "Rate your mind pal" is shown first. From the soft Menu, select Start. The scrambled puzzle is displayed. The arrow keys move the empty space, displacing tiles accordingly. To change the arrow behavior, select Options from the soft menu, and choose reverse arrows, then click OK. From the menu you can Reset, or change options.

WormGame. From the soft Menu, select 1, Launch. Use the arrow keys to move the worm to the green box without touching the edge of the window. When the game is launched, use the soft menu to change game options.

PushPuzzle. Use the blue ball to push the orange boxes into the red squares in the fewest number of moves.

3.6.5 Running Network Demo

This demo has two MIDlets: Socket Demo and Datagram Demo. Each demo requires you to run two emulator instances so that you can emulate the server and client relationship. For example, run the demo on JavaMEPhone1 and JavaMEPhone2.

3.6.5.1 Socket Demo

In this application one emulator acts as the socket server, and the other as the socket client.

  1. In the first emulator, launch the application, then select the Server peer. Choose Start. The Socket Server displays a status message that it is waiting on port 5000.

  2. In the second emulator, launch the application, select the Client peer, then choose Start. Choose Start to launch the client. The Socket Client displays a status message that indicates it is connected to the server on port 5000. Use the down navigation arrow to highlight the Send box. Type a message in the Send box, then choose the Send soft key.

    For example, in the client, type Hello Server in the Send box. Choose Send from the menu. The server emulator activates a blue light when the message is received.

  3. On the emulator running the Socket Server, the status reads: Message received - Hello Server. You can use the down arrow to move to the Send box and type a reply. For example, Hello Client, I heard you. From the menu, select Send.

  4. Back in the Socket Client, the status is: Message received - Hello Client, I heard you. Until you send a new message, the Send box contains the previous message you sent.

3.6.5.2 Datagram Demo

This demo is similar to Socket Demo. Run two instances of the emulator. One acts as the datagram server, and the other as the datagram client.

  1. In the first emulator, launch Datagram Demo, then select the Server peer. Choose Start. Initially, the Datagram Server status is Waiting for connection on port 5555, and the Send box is empty.

  2. In the second emulator, launch Datagram Demo, select the Client peer, ensure the port number is 5555 and choose Start. The Datagram Client status is: Connected to server on port 5555. Use the down navigation arrow to highlight the Send box. Type a message in the Send box, then choose the Send from the menu. For example, type Hello datagram server. From the menu, select Send.

  3. On the emulator running the Datagram Server, the status displays: Message received - Hello datagram server. You can use the down arrow to move to the Send box and type a reply to the client.

  4. In the Datagram Client, the status field displays the message received from the server. The Send box contains the last message you sent. Overwrite it to send another message.

3.6.6 Running PhotoAlbum

The PhotoAlbum demo displays both static and animated images. When you are displaying an image, you can use the Options soft menu to change the borders. If the image is animated, you can change the speed of the playback.

3.6.7 Running UIDemo

UIDemo showcases a variety of MIDP user interface element implementations. Most elements have some interactive capability (navigate and select) and some allow keypad or keyboard input.

Input interaction is similar across demos. You can choose items from lists or type in data.

This demo implements three list selection methods:

  • Exclusive (radio buttons)

  • Multiple (check boxes)

  • Pop-Up (a drop list).

When entering data, you can use the soft menu to apply one of the following input types to text boxes and fields (note, some elements do not use all input types). When a field is selected, the soft Menu label displays Qwerty. Open the menu and you see the input types numbered 1 through 5.

  1. Qwerty. Any character on the keyboard

  2. 123. Any numeral

  3. ABC. Any letter

  4. Predict. Predicts next character based on prior input

  5. Symbols. Opens a list of symbols; click to make a selection.

  6. Virtual. Click keys on a virtual keyboard to enter data.

The Qwerty, 123, and ABC categories act as filters. For example, if you assign 123 to a field and you type "abc", nothing is entered in the field.

When you finish a demo, select the home button to return to the UIDemo launch page: back button

CustomItem. This demo features text fields, and text fields in table form. To type in the table, select a cell, then click to open a text entry panel and type your input. From the menu, select OK.

StringItem. Displays labels, a hyperlink, and a button. The soft menu action varies depending on the selected element.

Gauge. Interactive, non-interactive, indefinite and incremental gauges.

Alert. Uses pop-ups to display alerts. Set the alarm type and the length of the timeout from drop lists. Select the alert type and select the Show soft button.

ChoiceGroup. Radio buttons, check boxes, and pop-ups on one screen.

List. Select exclusive, implicit, or multiple to display the list type on a subsequent screen.

TextBox. Use text fields, radio buttons, check boxes, and pop-ups. Select a text box type and press the Show button.

TextField. Text fields with the six input types.

DateField. Set date and time using drop lists.

Ticker. A scrolling ticker.

3.7 Running IMP-NG Sample Projects

This section describes how to use demos created specifically for the IMP-NG platform (see Section 2.1.2, "IMP-NG"). Because IMP-NG is headless the only user interface is to observe application status in the emulator's external events generator, or in the Output window (or the console if you execute the demo from the command line).

With the exception of I2CDemo, the sample projects in this section can be run on the emulator or on a real device.

See the Oracle® Java ME Embedded Getting Started Guide for the Reference Board Platform and the Oracle® Java ME Embedded Getting Started Guide for the Windows 32 Platform These documents are available on the Java ME documentation site at http://docs.oracle.com/javame/index.html.

3.7.1 GPIODemo

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

GPIODemo on the Emulator

  • Run GPIO demo on an IMP-NG emulator.

  • Click the GPIO tab. This view approximates the device actions.

  • Choose Device > GPIO to open the external events generator, and click the GPIO tab. A single click on a button turns on LEDs indicating the button pushed and the pin affected. This information is also written to the Output window.

    Beneath each pin you can click the blue wave button to open the wave generator. The wave generator simulates the frequency and duration of the signal to the LED.

  • Press Pin 5 (button 1) to turn on LED 1, press again to turn off LED 1.

  • Press Pin 6 (button 2) to turn on LED 2, press again to turn off LED 2.

  • Press Pin 7 (button 3) and check whether PORT 1's output value is 3. Press PIN 7 and check whether PORT 1's output value is 0.

GPIODemo on the Reference Board

The buttons are wired by GPIO. Assuming that you are looking at the board and the Reset button is on the bottom left:

  • Reading from left to right, the LEDS are labelled: PH.3, PH.6, PH.7, PI.10, PG.6, PG.6, PG.8, and PH.2.

  • The buttons, from left to right, are Reset, Wakeup, Tamper, and User.

    The Wakeup button corresponds to PH.3 (Listener 1 Pin 5).

    The Tamper button corresponds to PH.6 (Listener 2 Pin 6).

    The User button corresponds to PH.7 and PI.10 (Listener 3 Pin 7).

  • Pressing Wakeup turns on the light, and releasing turns off light.

  • When you press Tamper, the initial press does nothing (listener false). Releasing turns on light. After that, pressing turns light on and releasing turns light off. (Press listener is false and Release listener is true, as shown in the console output.)

  • When you press User, the initial press does nothing. Release turns on two lights. After that, pressing turns two lights off and releasing turns two lights on. (Press listener is false and Release listener is true.)

3.7.2 I2CDemo

This demo is designed to work with the IMP-NG runtime for Windows 32. It has no user interaction.

  • Launch the I2C demo.

  • In the emulator, click the I2C tab.

    The demo acquires a slave named I2C_Echo, writes data to the slave, and retrieves it. The demo is successful if the Sent Data and Received Data matches.

3.7.3 NetworkDemoIMPNG

This demo is a headless version of Section 3.6.5.1, "Socket Demo."

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

NetworkDemoIMPNG on the Emulator

  • Create two instance projects of the NetworkDemoIMPNG sample project.

  • Right click on the first project and select Properties. In the Platform category choose the device IMPNGPhone1. In the Application Description category set the value of the property Oracle-Demo-Network-Mode to Server and click OK.

  • Launch the first project. It opens on the emulator IMPNGPhone1 and waits for a connection.

  • Right click on the second project and select Properties. In the Platform category choose the device IMPNGPhone2. In the Application Description category set the value of the property Oracle-Demo-Network-Mode to Client and click OK.

  • Launch the second project. It opens on the emulator IMPNGPhone2.

  • The client 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 output of the second project (the client) shows the following:

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

NetworkDemoIMPNG 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:

  • Right click on the first project (the server) and select Properties. In the Platform category choose the device IMPNGPhone1 (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 choose the device IMPNGExternalPhone1 (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 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
    

3.7.4 PDAPDemoIMPNG

This demo is a headless version of the PDAPDemo file browser in Section 14.3.1, "Browsing Files."

PDAPDemoIMPNG on the Emulator

Follow these steps to run the demo on the emulator:

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

    Documents and Settings\user\javame-sdk\version\work\IMPNGPhone1\appdb\filesystem\root1

  • Right click on the project and select Properties. In the Platform category choose the device IMPNGPhone1 and click OK.

  • Launch the project. It runs on IMPNGPhone1.

  • On the emulator menu, select Device > File Connection to see a list of mounted file systems.

  • Open a terminal emulator and create a raw connection to localhost on port 5001.

  • 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

    PDAPDemoIMPNG on the Board

    Follow these steps to run the demo on the board:

    • Right click on the project and select Properties. In the Platform category choose the device IMPNGExternalPhone1 and click OK.

    • Launch the project. It runs on the 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.