当前页面: 开发资料首页 → 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:
Java Standard Development Kit (JDK™) version 5.0
NetBeans Mobility 5.5 Pack for CDC Beta 2 (download
Windows version only)
Sun Java Toolkit 1.0 for CDC, Beta (login required for
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
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:
The commercial build that ships on the phone.
JavaOne Early Access developer build without the Java Debug Wire Protocol
JavaOne early access developer build with JDWP enables. To run a bundle
with JDWP debugging, you need to load this build.
Follow these steps to install a different build of the SavaJE OS on the phone.
- Extract (unzip) the zip file containing the desired build to the root
of the mini-SD card.
- Connect a USB/power cable to the handset.
- Power the handset while holding the Camera key down.
- 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.
- 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:
- From the main menu, choose Tools > Java Platform Manager.
- Select Java Micro Edition CDC Platform Emulator and click Next.
- Select the folder that contains the Sun Java Toolkit 1.0 for CDC, Early
Access and click Next.
- 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
- Choose File > New Project (Ctrl-Shift-N) from the main window.
- From Categories, select CDC. From Projects, select CDC Application. Click
- In the Select Platform page, use the drop-down menu to choose
as the Device. Leave the Platform and Profile settings as they are.
- In the New CDC Application panel:
- Name the project
- You do want to create a Main class, even though it's really an Xlet
class, not a Java SE class with
- Change the package/classname to
- The Application Name is the name that will show up as the bundle title
(on the My Application Menu).
Press Finish. The IDE creates an Xlet shell to edit.
Right-click the project name and choose Properties.
After you have added the Xlet code, choose Run > Run Main Project to
run the application in the emulator. The application displays in the
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
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.
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".
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
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.
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
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:
- Right-click the Libraries folder of your NetBeans project and click Library.
- Click the Manage Libraries button.
- Click the New Library button.
- Name the library (for example,
SavaJeDeveloperLib) and click
- Click the Add JAR/Folder button and navigate to the
file on your system.
- 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
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
To set up the networking software for JDWP operation:
Connect the phone to the PC using a USB cable.
Choose Start > Settings> Control Panel > Network
Locate the GSPDA Mobile Device CDC Ethernet Drivers,
which might show up as a Local Area Connection.
Right-click and choose Properties, then select Internet
Protocol (TCP/IP) and click the Properties button.
Select Use the following IP Addresses and enter the
IP Address = 192.168.254.2
Subnet mask = 255.255.255.252
Setting Up JDWP on the NetBeans IDE
- In the Projects window, right-click on your project and choose Properties
- 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.)
- Check the box to add debug information to the JNLP file.
- Click OK.
Debugging a JDWP-Enabled Bundle
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
You should now be able to ping the phone from your PC.
Enter from the command prompt:
From NetBeans 5.5, choose Run > Attach Debugger.
Set the following values in the dialog box:
Connector = SocketAttach
transport = dt_socket
host = 192.168.254.1
port = 9462
The following output should appear in the output Debugger
Attaching to 192.168.254.1.9462
user program running
breakpoint hit at line 82 in class HelloXlet by thread main.
about the NetBeans Mobility Pack for CDC.
Go to SavaJe. com
to learn more about the SavaJe OS and the Jasper S20 phone.