|
J2ME and J2EE technologies can be used together to create mobile and wireless applications. As the J2ME technology emerges and more profiles become available on J2ME-enabled devices, the ability to put enterprise data and services onto cellular phones, pagers, PDAs, and other wireless devices using Java becomes increasingly feasible.
Developers may use Studio to build, package, execute and debug J2ME applications, with the Java 2 Platform, Micro Edition (J2ME)Wireless Tool Kit. The following sections describe how to create MIDP applications using J2ME Wireless Module in Studio.
Install J2MEWTK (J2ME Wireless Tool Kit) following the given steps:
Pramati Studio supports the 1.0.4 or a greater version of J2ME Wireless Tool Kit.
For detailed information on how to install the J2ME Wireless Module, refer the J2ME Wireless Tool Kit User's Guide.
Once the J2ME Wireless Tool Kit has been installed, configure the installed location in Studio. To do this,
MIDP applications, or MIDlets, are packaged into a MIDlet Suite. MIDlet Suites are a group of MIDlets that share resources at runtime. A MIDlet Suite includes:
MIDlet Suites may be created in two ways
To create a empty MIDlet Suite, right click on the Desk Root node and select New Folder > MIDlet Suite. This pops up a dialog, where the following information has to be filled in:
To create a MIDlet with existing source files, right click on the Desk Root node and select New Folder > MIDlet Suite. This pops up a dialog, where the following information has to be filled in:
To know how to import independent MIDlet files, read the section,"Importing existing MIDlets".
MIDP applications are also known as MIDlets. Follow the given instructions to add MIDlets to the MIDlet Suite:
Note: Use the Import Files option, available on a right click to add the resources (used by the MIDlets) to the MIDlet Suite.
To import existing MIDlets to the MIDlet Suite, right click on the MIDlet Suite node or any appropriate directory under the Suite, and select Import Files. All the resource files used by the MIDlets must also be imported in a similar way.
Studio allows the user to customize the MIDlet Suite properties. These properties include:
To customize the attributes, right click on the MIDlet Suite for which properties are to be set and select MIDlet Suite Attributes.
In the Attributes dialog that pops up, five types of properties can be set. Modify the required fields and click OK
Required This tab contains all the mandatory fields of the MIdlet. The values of these attributes may be edited after selecting it.
Optional Enter all the optional values of the MIDlet properties here
User Defined To add a new user defined property, click on Add. This creates a new row, where the attribute name and value can be entered. To remove the entry, select the row and click on the remove button.
MIDlets Specify all the MIDlet specific attributes, by entering the values here.Use the Move Up and Move Down buttons to change the order of the MIDlets in the Suite (the order in which they are listed when you launch the Suite).
Select MIDlets Select the MIDlets that are to be included for the application by checking from the list of MIDlets here. The MIDlets that are not checked, do not have entries in the .jad file, but their class files are packaged in the .jar file.
Click OK after making all the required changes in the all the tabs.
To compile a MIDlet in a MIDlet Suite, right click on the MIDlet node in the Desk and select Compile. To build MIDlet Suites, right click on the MIDlet Suite node in the Desk and select Build from the popup menu.
This builds the entire application under the selected MIDlet Suite. All the compilation messages are displayed in the J2ME Output tab in the Output Panel of Studio.
If no device to emulate is specified, the Emulator uses the default device, DefaultColorPhone, when a MIDlet is run. To change the default emulated device, click on Tools > J2ME Wireless Tool Kit > Select Default Device from the main menu. The next time a MIDlet is run, it will be emulated on the device chosen.
Running the application or exporting the MIDlet Suite to a Web Module, preverifies and packages the MIDlet Suite.
To run the application, right click on the MIDlet Suite to preverify, package, and run the MIDlet Suite. This pops up an Emulator, where the application is executed. All the runtime messages are displayed in the Run-output tab in the Output Panel of Studio.
The MIDlet Suite allows you to configure the Emulator device on which the MIDlets are executed. Select Tools > J2ME Wireless Tool Kit > Preferences from the main menu bar. This pops up the Preferences dialog, where the Emulator properties can be set, and click OK.
MIDlets can be hosted on any J2EE application Server, by packaging them in a WAR. To do this, right click on the MIDlet Suite and select Export to Web Module to export the JAD and the JAR files in the required Web Module.
The Web Module then needs to be deployed before trying to access the JAD file remotely. To launch the Emulator, right click on the JAD file in the Web Module and select Run. This runs the MIDlets by downloading them from the Server.
If the exported JAD files fail to execute, verify whether all the JAD attributes are correct. For example, all the required attributes must be specified and valid.
The JAD and the JAR files that are exported into Web Modules are not editable in Studio. All modifications to be made to these JAD files or the MIDlets must be made in the original MIDlet Suite and re-exported.
MIDlets may be debugged in Studio using the powerful Debugger. Follow the given steps, and debug MIDlets:
The user may now use the options, Step In, Step Over, or Step Out to continue debugging the MIDlet.
Choose Debug > Stop from the main menu to stop the current debugging session.
Open the j2me.props file stored in <install_dir>, and modify the value of the property, j2me.debug.port from 5000 to the new number.
#Take a backup before editing this file manually
#Mon Oct 07 12:15:11 IST 2002
j2me.preverify=bin\\preverify.exe
j2me.defaultdevice=bin\\DefaultDevicew.exe
MicroEdition-Configuration=CLDC-1.0
j2me.home=D\:\\WTK104
MIDlet-Version=1.0.0
j2me.utilities=bin\\utilsw.exe
MIDlet-Vendor=Company Name
MicroEdition-Profile=MIDP-1.0
j2me.Emulator=bin\\Emulatorw.exe
j2me.preferences=bin\\prefsw.exe
j2me.debug.port=5000
| Pramati Technologies © Copyright |
|