站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Netbeans 专题Developing for the SavaJe Mobile Platform

Developing for the SavaJe Mobile Platform

摘要: This guide will get you started quickly running and developing CDC Applications (Xlets) for the SavaJe Operating System (OS) using the NetBeans Mobility Pack. The tutorial takes you through some of the basic steps of working with the new project system. This document is designed to get you going as quickly as possible

The tutorial covers the following topics:

Software Needed for the Tutorial

Before you begin, you need to install the following software on your computer:

Optional Software and Hardware for the Tutorial

The first device created to run the SavaJe Mobile Platform is the Jasper S20 phone. Because the Jasper S20, the Sun Java Toolkit 1.0, and the NetBeans Mobility Pack are currently available only as preview editions, there is no emulator skin available for the Jasper S20. You can, instead, use the DefaultColorPhone device to simulate the behavior of the Jasper S20.

If you do have a Jasper S20, this tutorial will show you how to deploy the application to your device. Here is what you need:

Setting Up the Handset

The following steps describe the process for installing the software you need for the tutorial on the Jasper S20 phone.

Installing the SavaJE OS

NOTE: This procedure is for Jasper S20 handsets that have a previous version of the SavaJe OS installed and you want to retain existing calibration and factory settings.

There are three builds of the SavaJe OS that were distributed at JavaOne, and might be available from www.SavaJe.com:

Follow these steps to install a different build of the SavaJE OS on the phone.

  1. Extract (unzip) the zip file containing the desired build to the root of the mini-SD card.
  2. Connect a USB/power cable to the handset.
  3. Power the handset while holding the Camera key down.
  4. At the updater menu screen, select Factory Reset by moving the joystick down until "Factory Reset" is highlighted. Initiate the factory reset by moving the joystick to the right. Use the joystick to navigate to Yes and then select Yes by moving the joystick to the right.
    The phone should begin loading the new build. After the load is complete, you may be prompted to press any key to reboot the phone.
  5. The handset then reboots and displays the Xplore screen. If the battery charging screen displays during the reboot, press the power button to continue rebooting the phone.

The first time the handset boots after a factory reset, a Language/Locale selection menu displays. Make your selections by navigating with the joystick and pressing the joystick button. You are also prompted to set the time.

Registering the CDC Platform

In order to develop CDC applications for the SavaJe OS, you need to have the CDC platform registered in the IDE. This example will show you how to register the SavaJe OS. This platform currently maintains emulation for the Jasper S20 device.

To register the SavaJE Platform:
  1. From the main menu, choose Tools > Java Platform Manager.
  2. Select Java Micro Edition CDC Platform Emulator and click Next.

    selecting the platform type

  3. Select the folder that contains the Sun Java Toolkit 1.0 for CDC, Early Access and click Next.

    Screenshot of the Add Java Platform dialog with the directory "CDCTK10" selected.

  4. Click Next, then Finish.
    The IDE registers the CDC platform.

Developing Your Own Xlets

Follow these steps to create a new SavaJe bundle (CDC Xlet application).

Creating a New CDC Application

  1. Choose File > New Project (Ctrl-Shift-N) from the main window.
  2. From Categories, select CDC. From Projects, select CDC Application. Click Next.
  3. In the Select Platform page, use the drop-down menu to choose DefaultColorPhone as the Device. Leave the Platform and Profile settings as they are.

    Screenshot of the "New Project" dialog
  4. In the New CDC Application panel:
    • Name the project newcdc.
    • You do want to create a Main class, even though it's really an Xlet class, not a Java SE class with main().
    • Change the package/classname to Mainxlet.
    • The Application Name is the name that will show up as the bundle title (on the My Application Menu).

    Screenshot of the New CDC Application dialog

  5. Press Finish. The IDE creates an Xlet shell to edit.

    Screenshot of the Projects window of the NetBeans IDE, with the new project and its sub-files listed.
  6. Right-click the project name and choose Properties.
    • Add some text to the Description field (this is a workaround for a bug that is to be fixed). The other fields defined in Properties contain information that goes into the bundle.jnlp file.
    • If you have a Jasper S20 phone, under the deployment category in Project Properties, change the mount point to the drive letter that your SD card or phone (via USB mass storage) shows up as. This will let you deploy bundles to the SD card.
  7. After you have added the Xlet code, choose Run > Run Main Project to run the application in the emulator. The application displays in the DefaultColorPhone device emulator. You might need to click on the device screen to get the keys to work.
    In the image below, we dragged a Jcheckbox object into the design form and renamed it "Test Button".
  8. Optionally, you can deploy a bundle to the SD card. Right-click the project name, then select Deploy Target Bundle. If your bundle builds correctly, and you have an SD card or phone connected, this should work fine.
    • Insert the SD card in the phone and your bundle should show up under My Applications.

    NOTE: If you are using the USB mass storage drivers to mount the SD card from the phone, you will need to eject or safely remove the SD card before the bundle shows up under My Applications. The SD card cannot be simultaneously mounted by the phone and the PC.



    Screenshot of the NetBeans IDE and device emulation running

Adding SavaJeDeveloper.jar as a Platform Library

If you need to use any net.savaJe classes in your application, you need to add the SavaJeDeveloper.jar file as a platform library to compile against. Do not add SavaJeDeveloper.jar as a jar file for your application. If you do, it will be included in the application classes.jar file, making it larger than necessary.

The SavaJeDeveloper.jar files in located in the jars directory on the supplied CD, and might be available at www.savaje.com.

To add SavaJeDeveloper.jar as a platform library:

  1. Right-click the Libraries folder of your NetBeans project and click Library.
  2. Click the Manage Libraries button.
  3. Click the New Library button.
  4. Name the library (for example, SavaJeDeveloperLib) and click OK.
  5. Click the Add JAR/Folder button and navigate to the SavaJedeveloper.jar file on your system.
  6. Click OK, then click Add Library. and the new library should show up under the Libraries folder on your project.

Using the Java Debug Wire Protocol (JDWP) to Debug Bundled Applications

You can use the NetBeans IDE with a SavaJe OS phone to debug applications on your PC while running them on your phone.

Note: To communicate from a Windows PC to a phone running SavaJe OS via the USB Cable, you'll need to install the GSPDA Mobile Device Software (MCCI USB drivers).

Setting Up JDWP on Windows

You should already have the GSPDA Mobile Device software installed.

To set up the networking software for JDWP operation:

  1. Connect the phone to the PC using a USB cable.
  2. Choose Start > Settings> Control Panel > Network Connections.
  3. Locate the GSPDA Mobile Device CDC Ethernet Drivers, which might show up as a Local Area Connection.
  4. Right-click and choose Properties, then select Internet Protocol (TCP/IP) and click the Properties button.
  5. Select Use the following IP Addresses and enter the following values:
    IP Address = 192.168.254.2
    Subnet mask = 255.255.255.252

Setting Up JDWP on the NetBeans IDE

  1. In the Projects window, right-click on your project and choose Properties > Deployment.
  2. Enter a numeric value for the debug port (typically 9462, but it can be any value as long as it is the same port the debugger uses while attaching to the phone.)
  3. Check the box to add debug information to the JNLP file.
  4. Click OK.

Debugging a JDWP-Enabled Bundle

  1. Before running a JDWP session, you need to start networking on the phone. On the phone, go to My Applications and click the NetStart icon (a wrench) to start networking. The NetStart Xlet has no user interface, so the background might display for a few seconds while networking services start.
  2. You should now be able to ping the phone from your PC.
    Enter from the command prompt:

    ping 192.168.254.1
  3. From NetBeans 5.5, choose Run > Attach Debugger.
  4. Set the following values in the dialog box:

    JPDA Debugger
    Connector = SocketAttach
    transport = dt_socket
    host = 192.168.254.1
    port = 9462
  5. The following output should appear in the output Debugger window:

    Attaching to 192.168.254.1.9462
    user program running
    breakpoint hit at line 82 in class HelloXlet by thread main.

Next Steps