C H A P T E R  6

The Currency Converter Networked Mobile Data Application

Now that you have seen how to build the Currency Converter MIDlet, this chapter will show you a modified version of the same application. In this client/server version of the Currency Converter, the application can call the server to check the current rates of exchange before completing currency conversion calculations.

This chapter will guide you through installing and running the Currency Converter Wireless application. The next chapter will show you how to construct both client and server parts of the application, and how to connect them using the J2ME Wireless Connection Wizard.



Note - Because the previous Currency Converter example application uses identical filenames to the application you are about to install, unmount the Currency Converter /src filesystem before you continue. Otherwise, the similarity of filenames can cause compilation errors.



This chapter is organized under the following topics:


Description of the Currency Converter Application

The following files comprise the client MIDlet Suite, converter_networked:

The server side of the application includes the following files:


Installing the Currency Converter Wireless Application

The Java Studio Mobility provides an Examples Setup wizard that installs the complete example in the IDE.



Note - As with all future instructions, it is assumed the Java Studio Mobility IDE is up and running on your desktop.



To install the Currency Converter:

1. Choose Help right arrow Examples Setup Wizard.

The Examples Setup wizard opens.

 [ D ] 

2. On the Examples Setup page, check the Currency Converter Wireless Connection Example box. Click Next.

The installation page opens, with a progress bar that indicates when the example is installed.

3. Click Finish to close the Example Setup wizard.

The Currency Converter Wireless Connection example is installed and mounted in the default examples filesystem. You can see the directory in the Filesystems window.

Screenshot showing the Currency Converter Wireless Connection Example application mounted in the Explorer. 


Compiling and Running the Application

Now that you have installed the application, the next section shows you how to compile and run the application in a device emulator.

1. In the Filesystems window, expand the Currency Converter Wireless Connection Example: /client filesystem node.

A Converter folder and Converter_networked suite node display.

Screenshot of Explorer window menu tree with converter folder and converter MIDlet suite nodes visible.  

2. Right-click on the MIDlet suite and choose Execute.

The Execute function compiles the MIDlet application, if necessary, before it executes the application.

As with the first Currency Converter application, the MIDlet suite runs on the default DefaultColorPhone skin within the J2ME Wireless Toolkit 2.1 installation.

Screenshot of the DefaultColorPhone device emulator, with Currency Converter application displayed in the device.A callout points to the position of the Launch button. 

Now you're ready to test the application in the device emulator.

3. Select the currency you want to convert by clicking the up and down arrow keys on the Select button.

You can select Dollars, Euros, or Yen.

4. Enter the currency amount to convert by clicking the emulator's numeric keys.

The application makes the conversion calculations and displays the results.

5. Click the button underneath the word "Exit" to exit the application.

6. Click the red button in the upper right corner to close the emulator.

 [ D ] 


Summary

In this chapter, you went through the few steps it takes to compile and run a simple MIDlet in an emulator device.

In the next chapter, you will learn how to modify the Currency Converter application so that it runs as a client/server application on a network.