NetBeans is an Open Source Java IDE that comes with many nifty features. It does not only feature code completion and a debug mode, but also allows you to design MIDlets instead of coding the screens by hand. Importing Nokia's sample applications into NetBeans saves time, prevents typos, and increases developer convenience.
In short
- This article covers how to import one of Nokia's sample applications, Contactless, into NetBeans IDE 5.5.
- Using NetBeans IDE saves time with features such as code completion, syntax checking and debugging.
About Nokia's Contactless sample application
Contactless is part of Nokia's JSR 257 RI SDK, the first SDK that allows Java developers to write their very own NFC MIDlets. For now, the Nokia 6131 NFC is the only phone to support JSR 257. The JSR 257 API, currently, can only be used to operate on NFC tags, and not yet on NFC peers.
NetBeans bundled with Mobility Pack
The mobility utilities don't come standard with NetBeans 5.5, but with a special add-on called Mobility Pack. I'll assume you've downloaded and installed first a Java JDK, and then both NetBeans and Mobility Pack.
Why use NetBeans?
First off, since I've been using it for a few years now, and I find it a very adequate IDE. The JSR 257 RI SDK comes with only a buildfile and some sources, so editing the sources had to be done using a text editor.
Text editors don't know much about code and/or code completion, so many times I have to bounce back and forth between my editor and the API documentation to get the correct names.
And how about context compiling? If you type something into NetBeans, it will do a quick 'background check' on whether your syntax is correct, and if you've imported what you are using on the spot.
If not, you'll get a red line under the line where NetBeans thinks you've erred.
And another thing I frankly haven't yet used with this SDK: The MIDP designer mode. Using NetBeans + Mobility pack, you can create your MIDlet's screens in a visual design mode.
Using NetBeans will save me time not having to switch between editor and API documentation, will prevent me from getting compiler syntax errors, and has many more features that make my life easier. I can even debug my applications with it!
Adding the JSR 257 RI SDK emulator
Here, we'll cover how to use the emulator shipped with Nokia's JSR 257 RI SDK into NetBeans 5.5. These instructions are not specifically for the RI SDK, but can be used with any emulator package that conforms to the standard specifications. This means that you can import virtually any J2ME emulator into NetBeans using these instructions.
Select Tools -> Java Platform Manager.
Click Add Platform, and select Java Micro Edition Platform Emulator.
Frankly, the platforms listed showed up automagically! Appearantly, NetBeans had already found them in my c:\Nokia\Devices directory.
As you can see, I have some more emulators in my Devices directory. We'll only need the JSR 257 emulator. Click Next, and you'll get a page about the Platform Details. If all looks OK to you, and you agree with the Platform Name, click Finish.
Importing the project
In this example, we'll import the project called Contactless into our NetBeans IDE.
Select File -> New Project -> Mobile -> Import Wireless Toolkit Project.
Click Next, and in the next screen, specify a different WTK location.
Here, you must locate your Nokia JSR 257 RI SDK's sample applications.
On my computer, they're located at C:\Nokia\Devices\JSR_257_RI_1_0\samples\contactless.
We'll keep the name ImportedProject-Contactless.
Please note that NetBeans will not copy the source files from the Contactless project into your new project folder. When you change your source files, the original files will be affected, so that you can keep compiling your project in Wireless Toolkit, if you prefer to.
Next is Default Platform Selection. Don't use J2ME Wireless Toolkit 2.2 here, but use the platform we've just added.
Now click Finish. Congratulations! You have now successfully imported the Contactless project into NetBeans.
The project should look like this:
Because the emulator conforms to the standard conventions, you now have the Debug option for free! Just select Run -> Debug (F5) to start debugging in the supplied emulator.
The emulator doesn't look as if it's the prettiest S40 emulator around, but it works OK:
When the MIDlet enables its NFC functions, the emulator will show the Contactless Simulator dialog that you can use to place various tags inside and out of the RF field.
Conclusion
This concludes on how to import a Nokia sample project into NetBeans. Using NetBeans instead of plain command-line Ant and a text editor might be an investment, but saves time in the future, and contributes greatly to developer productivity.
0 comments:
Post a Comment