NetBeans IDE and the Motorola Java ME SDK

Document Sample
NetBeans IDE and the Motorola Java ME SDK Powered By Docstoc
					                    NetBeans IDE and
                    Motorola J2ME SDK




                          April 1, 2006




Technical Article
                              NetBeans IDE and Motorola J2ME SDK
                                                  By
                                            Motocoder staff




N      etBeans, developed by Sun, is one of the most popular free Java development tools nowadays and
       the Motorola J2ME SDK can work perfectly with this tool. This article focuses on how to
       integrate the Motorola SDK into NetBeans IDE 5.0 and how to develop J2ME applications easily
in this popular IDE.


Introduction of the Motorola J2ME SDK

The Motorola J2ME SDK has been divided into two SDKs recently. Before you start developing J2ME
applications, you may first have to decide which handset you are writing your application for. This
decision will help you select the proper SDK. The latest SDKs at the time this article is written are:
   ! Motorola J2ME SDK v.5.4.2 for Linux OS Products
   ! Motorola J2ME SDK v.5.3.1 for Motorola OS Products

Both versions of the Motorola J2ME SDK are available from Motocoder.com

The Motorola J2ME SDK v.5.4.2 for Linux OS Products
This SDK contains emulators for Linux OS based phones. They are divided into two groups depending
on the KVM on the actual devices. The handsets in each group are:

                                       Table 1: M.x emulators
       Group    Folder in SDK        Handsets
       M.1      EmulatorM.1          A760/A760i, A768/A768i, A728
       M.3      EmulatorM.3          A780, E680/E680i
Currently all emulators can integrated into any UEI-compliant IDEs and work well. Those UEI-
compliant IDEs include NetBeans IDE, Eclipse, JBuilder, etc.

The Motorola J2ME SDK v.5.3.1 for Motorola OS Products
This SDK contains emulators for Motorola OS based phones. They are divided into three groups
depending on KVM for the actual device. The handsets in each group are:
                                       Table 2: A.x emulators
       Group    Folder in SDK        Handsets
       A.1      EmulatorA.1          A630, A845, C380, C381p, C381/C386, C384/C385/C390/C391,
                                     C650/C651, C698p, E375, E398, E550/V535/V560, T725,
                                     V180/V185/V186/V188, V220/V220i/V226, V3 (CLDC 1.0)/RAZR
                                    V3b, V300/V400/V500, V330/V547/V551/V555, V400p/V303p,
                                    V540/V545/V550, V600, V600i, V620, V635, V80
       A.3      EmulatorA.3         C975, C980, E770 (New), E1000/E1000R, E1070 (New), RAZR
                                    V3x, V975, V980
       A.4      EmulatorA.4         L2/L6, PEBL, V3 (CLDC 1.1), RAZR V3i, ROKR E1, SLVR,
                                    V190/V191, V230/V235, V360/V361, V557/V557p
Here, A.3 and A.4 emulators are UEI-compliant as well. The A.1 emulators support UEI commands, but
only support one default phone skin.


Integrating the Motorola SDK with NetBeans IDE 5.0

Before beginning the integration of the Motorola SDK, install NetBeans IDE 5.0 and the Mobility Pack
5.0 first. Those tools can be downloaded from the following sites:


   •   www.netbeans.org
   •   http://gceclub.sun.com.cn/download.html - for China Region


Obviously, the Motorola SDK also should be installed as well as NetBeans IDE.
Start the NetBeans IDE, select Tools # Java Platform Manager to open the Java Platform Manager
dialog as illustrated in Figure 1.




                          Figure 1: The Java Platform Manager dialog box
In this dialog, all integrated platforms are listed – such as JDK, J2ME Wireless Toolkit, etc. The
Motorola J2ME SDK will be listed here later. Click the Add Platform button to select which type of
platform you want to integrate as illustrated in Figure 2.




                                   Figure 2: Select Platform Type

Here, select Java Micro Edition Platform Emulator and click Next.




                                  Figure 3: Select Platform Folders

Click the Find More Java ME Platform Folders… button, and select the emulator group folders listed
in Tables 1 and 2.
                               Figure 4: Add Motorola Emulator Folders

After the target emulator folders are added, click Next.




                                    Figure 5: Select Platform Folders


   Note: If you add more than 1 A.x emulator group, you will have to change platform name in the
   dialog illustrated in Figure 5. Otherwise, NetBeans shows an error because both A.x emulators
   have the same platform name. The name can not be modified after you click Finish unless you
   remove the platform and add it again.

Click Finish and check to see that you have integrated your intended emulators as illustrated in Figure 6.
                                    Figure 6: All platforms listed

Close this dialog. Next we will create a simple MIDlet in the NetBeans IDE.


Developing J2ME applications for Motorola Phones in Netbeans IDE 5.0

NetBeans can help developers develop MIDlets quickly and easily as shown in the following steps.
1.   In the NetBeans IDE environment, click File # New Project to open the New Project dialog box as
     shown in Figure 7.
                                   Figure 7: The New Project dialog

2.   Select “Mobile” in the Categories pane and “Mobile Application” in the projects pane, and click
     Next. In the dialog box shown in Figure 8, enter the project location and project name. Check the
     “Set as Main Project” checkbox. If “Create Hello MIDlet” checkbox is checked, a default hello
     MIDlet will be generated. Uncheck the “Create Hello MIDlet” checkbox, and click Next.




                     Figure 8: Defining the project in the Name and Location dialog
3.   In the “Default Platform Selection” dialog box, specify one Motorola emulator platform and one
     target device as shown in Figure 9. Click Next.




                         Figure 9: The “Default Platform Selection” dialog box
4.   In the “More Configurations Selection” dialog box, check applicable target phones as shown in
     Figure 10 if more configurations are needed. This is a new feature in NetBeans IDE 5.0 which is
     very useful for developers who want their MIDlets to run on several different models of Motorola
     phones.




                      Figure 10: The “More Configurations Selection” dialog box

5.   Click Finish to create a new blank J2ME project.
6.   Click File # New File, and in the “New File” dialog box select “MIDP” under categories, then
     select “Visual Midlet” under File Types as shown in Figure 11. A “Visual Midlet” is a MIDlet that
     can be edited in a visual UI editor. If you only want to generate a simple MIDlet, you may choose
     “MIDlet” under the “File Types” panel. If you want to have a MIDlet with a canvas as its display,
     you may choose “MIDP Canvas” in the File Types panel.
                                    Figure 11: Choose the file type
7.   Click the “Next” button, and give the MIDlet a name and MIDP class name as shown in figure 12.




                        Figure 12: Entries for the Name & Location dialog box

8.   Click Finis. The NetBeans IDE with the automatically generated visual MIDlet is shown in Figure
     13.
                Figure 13: NetBeans IDE with the automatically created visual MIDlet
9.   Drag a screen component, for example, a Form, from the right side panel into the Flow Design view
     of the workspace. Modify the form’s properties in the “Properties” panel as shown in Figure 14.




                             Figure 14: Modifying Component Properties
10. Drag the pointer near the Start Point into the Form component as shown in Figure 15. It will connect
    the Start Point with the Form component shown as Figure 16. This means that the Form component
    will be the start point of MIDlet which will be displayed first after the MIDlet is started.
                 Figure 15: Connecting                             Figure 16: Connected
11. Double click the form component to switch to Screen Design view in the workspace. Drag an “Exit
    Command” into the Device Screen area as shown in Figure 17.
12. Click the Edit link to open the “Action” dialog box. In this dialog, select the Exit application radio
    button as shown in Figure 18. Click OK to close this dialog.




     Figure 17: Screen Design view                              Figure 18: The “Action” dialog box
13. Add more UI components as desired.
14. Return to the Flow Design view by clicking the Flow Design tab at the top of the screen. The “Exit
    Point” will be connected with the Exit command as shown in Figure 19.
                              Figure 19: “Exit Point” and Exit Command
15. Open the Project Properties dialog box (under File # Project Name # Properties). In the
    “Platform” category, uncheck all unnecessary packages as shown in Figure 20.




             Figure 20: All unnecessary packages unchecked in the properties dialog box
16. Expand the “Project Configuration” dropdown list box. Because we checked the RAZR_V3x
    checkbox at step #4, there will be one more configuration. This feature is very useful when you
    want to deploy your MIDlet on different models of Motorola phones, which may have different
    screen sizes or API packages. Select RAZR_V3x – detail settings are shown in Figure 21.
                             Figure 21: Multiple project configurations
17. Run the Main Project. The MIDlet runs well on the V360 emulator as shown in Figure 22. Thus far,
    we have built a MIDlet application without writing any actual code.
                            Figure 22: Testing your MIDlet on the emulator




Conclusion
   NetBeans enables developers to set up a UI-based application very quickly. It is especially useful for
   newcomers to J2ME application development.


References
1. Motorola J2ME SDK description, http://www.motocoder.com/

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:304
posted:5/1/2010
language:Indonesian
pages:14
Description: netbeans-platform pdf