- returnBlackberry Development using Netbeans Why develop in Netbeans? - The Rim JDE has it's good and bad points, the good are the excellent debugging and very fast build time but it's let down in the editor itself, there aren't many added features and the UI itself feels a little sluggish, the latest versions have limited intellisense but it's nothing compared to hitting ctrl-space on a keyword in Netbeans - you get the full javadoc and this in itself saves a huge amount of time, add to this excellent refactoring, masses of keyboard shortcuts, the ability to make modules and the snappy interface itself and you'll not want to go back to the Rim JDE - at least for coding; I've found the quickest and easiest way to develop for Blackberry is to use a combination of both environments, Netbeans for the developement and Rim JDE for building and debugging. You can develop one project in both apps by firstly setting up the directory in Netbeans, then, from the Rim JDE create your project .jdp file in the Netbeans project root directory and add the source files - you can now safely edit from either environment but benefit from the advantages of both. Please let me know if you find any errors or missing steps: ![]() Installation and setup: Step 1 - download and install Suns Java SDK Step 2 - download and install Netbeans IDE Step 3 - download and install Netbeans Mobility Pack Step 4 - download and install RIMs Blackberry JDE Step 5 - Launch Netbeans, from the toolbar select tools > java platform manager > add platform and select 'custom java micro edition platform emulator' Step 6 - Enter (or paste) Rims JDE home directory, for example: 'C:\Program Files\Research In Motion\BlackBerry JDE 4.2.0' as the Platform Home, then add 'Platform Name' (eg. Rim) and 'Device Name' (eg. Blackberry) Step 7 - Select 'Next', From the 'Bootstrap Libraries' list, remove every item except 'net_rim_api.jar' Step 8 - Select 'Next', Ignore the 'Sources' pane but add the path to the Blackberry javadocs, for example: 'C:\Program Files\Research In Motion\BlackBerry JDE 4.2.0\docs\api\' then click 'finish' Step 9 - Restart Netbeans ![]() Create a simple Blackberry Application: Step 1 - Create a new project by selecting 'mobile application' from the 'mobile category', uncheck the 'Create Hello Midlet' option Step 2 - Select the Blackberry platform that you've just created above Step 3 - Add this xml data to the build.xml file which is visible if you select the 'Files' pane Step 4 - Next you need to create an .alx file which is a Blackberry 'Application Loader' xml file, in the 'Files' pane, right-click and select 'new' > 'empty file' Name the file the same as your application (eg. myApp.alx), and add this xml data [important - only use numerics in the version number, any letters can cause issues for OTA installing of the application when you're done, for example do not use any 'beta' version notifiers like b1.0 Step 5 - You're now ready to start writing your application, switch back to the 'Project' pane and create your application, native Blackberry apps extend the UiApplication class instead of Midlet so you'll have cheat Netbeans by entering your main class as the Midlet: right click on your application in the project pane and select 'Properties', under 'Application Descriptor' > MIDLets enter the name of your class that extends UiApplication (ignore any warnings) Step 6 - Right click on your project and select 'Clean and Build', once you know your application will build select 'Debug' from the same menu. Netbeans should spawn the 'Rim Remote Debug Server' and the Blackberry Simulator, all your System.out.println statements will appear in the Debug Server not in the Netbeans output pane. ![]() Add Blackberry specific Netbeans Modules: ![]() String to Long module [more information] Step 1 - Download the Blackberry String to Long Module Step 2 - Extract the zip, in Netbeans goto > Tools > Update Centre Step 3 - Select the 'Install Manually Downloaded modules (.nbm files) radio button and select 'Next' Step 4 - Select 'Add' and locate the String2long.nbm module, follow the installation steps and ignore and warnings Step 5 - Once installed the String2Long module can be found on Netbeans's main toolbar, in the 'Edit' menu, or it can be invoked by using ctrl-shift-w, select the string you want a Long representation of and invoke the module, a new output pane will appear with some text ready to copy-and-paste into your class. (For more info on why this module is useful please refer to the Blackberry Development Guide pdfs available on the main Blackberry site, a Long representation of a string is used when creating persistent store object which are represented by a SHA1 Hash) ![]() Blackberry Template module [more information] Four class templates tailored towards Blackberry development, create a new applications class, a screen class, a popup screen class and a soap/sax class. Using these templates you can quickly build up the framework of your application. The soap/sax class is designed to be used with the kSoap j2me library. Step 1 - Download the BlackberryTemplates Module Step 2 - Extract the zip, in Netbeans goto > Tools > Update Centre Step 3 - Select the 'Install Manually Downloaded modules (.nbm files) radio button and select 'Next' Step 4 - Select 'Add' and locate the BlackberryTemplates.nbm module, follow the installation steps and ignore and warnings Step 5 - Once installed invoke the new file menu by the Netbeans menu, right clicking on your project or by hitting ctrl-n, there should be a new 'Blackberry' option Step 6 - Select the type of class you want to create, using this module you can have a native Blackberry application running in under a minute. Details: To create a Blackberry app using these modules you could create a new BlackberryScreenClass, inside the screen class add a new labelfield: public newBlackberryScreenClass() { add(new LabelField("Test")); } At this point you need to fix the imports, do this by clicking the balloon that pops up on the line of code, or by using the key combination: alt-shift-f You now have a screen but no main application class, so hit ctrl-n and create a new BlackberryApplicationClass, uncomment the pushScreen line and enter the name of your screen class. Create the application .alx file and edit the build.xml file as detailed above, in the project properties screen enter the main application class that extends UiApplication as the midlet name (ignore any warnings) - you are now ready to compile and test your application. ![]() >> return to articles menu |