The Mobile Information Device Profile and MIDlets, Part 5
Pages: 1, 2
If you experience problems with this example, check that the server is properly configured and that the JAR and JAD files are consistent:
- The URL that you supply to the AMS must point to an HTML file that contains absolute hypertext links to one or more JAD files. The HTML file for this example looks like this:
<HTML> <HEAD> <TITLE> J2ME in a Nutshell Example MIDlet Download Page </TITLE> </HEAD> <BODY> Install the example MIDlet suite for <A HREF="http://localhost:8080/Chapter3.jad">Chapter 3</A> of "J2ME in a Nutshell". </BODY> </HTML>
MIDlet-Jar-URLattribute in the JAD file must be an absolute URL pointing to the JAR file.
If the AMS locates any JAD files, it displays a list of the links that point to them, using the text within the
<A></A> tag pair to identify each MIDlet suite, as shown on the right side of Figure 3-12. This implementation does not display the MIDlet suite name or the JAR file size from the JAD file because it hasn't fetched it yet. To continue with the installation process, press the Install button.
At this point, the Wireless Toolkit AMS reads the JAD file from the server and uses the
MIDlet-Jar-URL attribute to locate and fetch the JAR file. If this process succeeds, a confirmation message appears as shown on the left side of Figure 3-13. After a short pause, the application manager switches back to its main screen, shown in the center of Figure 3-13. If you compare this to Figure 3-11, you'll see that the main screen now contains the name of the MIDlet suite that was just installed. The list of installed MIDlets is saved on the device, so this list will reappear when you next run the emulator. In the case of a MIDlet suite containing more than one MIDlet, the list in the main screen displays each suite together with the MIDlets that it contains. An example of this is shown on the right-hand side of Figure 3-13, in which a MIDlet suite called
Chapter5 containing individual MIDlets called
Ranking and others that are not visible in the screen shot, has been installed.
The main screen also includes an option that lets you launch MIDlets. If you select a MIDlet suite and choose this option, the usual MIDlet selector lets you pick the actual MIDlet to be run (see Figure 3-8). For a suite with multiple MIDlets, you can also choose an individual MIDlet from the main screen and launch it directly.
The Menu option provides access to the other application management features of the Wireless Toolkit AMS, presented in the form of a list, as shown in Figure 3-14.
Of these menu items, only the first three are worth discussing here. Each of these items operates on a MIDlet suite, so selecting any of them brings up another copy of the MIDlet selection screen so that you can choose the suite to which the command should apply.
The Info command displays the content of the JAD file that was fetched when the MIDlet suite was installed. Ideally, this information would be displayed to the user before the installation process starts, but, as noted previously, the Wireless Toolkit AMS does not implement this feature. Figure 3-15 shows the information displayed for the
Chapter3 MIDlet suite.
The Update command reinstalls the MIDlet suite from its original source. As noted earlier, the AMS can compare the MIDlet version in its installed JAD file and the one it acquires from the server to determine if it already has the latest version of a MIDlet suite.
The Remove option deletes a MIDlet suite and all its associated persistent storage from the device. The Wireless Toolkit AMS displays a warning message and asks the user for confirmation before performing this operation (see Figure 3-16).
The Wireless Toolkit AMS can be controlled from the command line as well as through its user interface. For example, you can install a MIDlet suite directly from a web server using the command:
c:\j2mewtk\bin\emulator.exe -Xjam:install=http://www.yourserver.com/ SOMETHING/Chapter3.jad
A complete description of the command-line arguments recognized by the Wireless Toolkit emulator can be found in Chapter 8.
1. The term Java Application Manager (or JAM) was originally used to describe the MIDP application management software. However, this resulted in confusion with the Java Application Manager software that is part of the CLDC reference implementation, which performs similar functions but with which it is incompatible.
Kim Topley has more than 25 years experience as a software developer and was one of the first people in the world to obtain the Sun Certified Java Developer qualification.
Return to ONJava.com.