The JDE Plug-in for Eclipse hasn’t been around as long as the stand-alone JDE and, until fairly recently, wasn’t as well supported, so there are still a few things that may not work 100 percent of the time. Also, the JDE Plug-in supports only JDE version 4.2.1 and later. Neither of these limitations is a concern for the majority of projects: the flakier parts are fairly obscure and don’t affect the final application, and version 4.2.1 is pretty much the minimum that most commercial applications should realistically support. The benefit is the richness of the Eclipse environment—mainly Eclipse’s editor, which has many more features than the one included with the JDE.
For what it’s worth, I have used earlier versions of the JDE Plug-in for Eclipse to create many professional BlackBerry applications, and even with its quirks, I would recommend it to any developer. We’ll walk through creating the same Hello World application with the JDE Plug-in for Eclipse, but I’ll skimp a bit on explanations of the code this time, so if you don’t understand something about the structure of the program itself, refer to the previous sections. If you haven’t installed the JDE Plug-in for Eclipse.
Creating the Project
With Eclipse, workspace creation is implicit, and the JDE Plug-in uses the same concept of workspace as Eclipse itself does. When you start Eclipse, you’re asked for a workspace location, which can be any directory. Select (or create) an appropriate one and click OK.
Creating a new workspace in Eclipse
If this is the first time you’ve opened this workspace, you’ll see Eclipse’s new workspace Welcome screen. There are useful things here, but for this tutorial, just click“Go to the workbench”.
The Eclipse new workspace Welcome page
To create a new BlackBerry project, click the File menu, and choose New ➤ Project. In the New Project dialog, select BlackBerry Project from the BlackBerry folder.
The Eclipse New Project dialog
Click Next; name your project HelloWorld, and click Finish. Your Eclipse workspace should contain a single project in the Package Explorer on the left-hand side. When expanded, the package should contain a folder named src, which is where all our source files will reside, and a reference to NET_RIM_BLACKBERRY, which is the BlackBerry runtime library containing the BlackBerry API.
New BlackBerry project in Eclipse
Creating the Application Classes
Here’s where the power of Eclipse will start to become apparent. We’ll create the same two classes for our project as we did with the JDE, but Eclipse will let us generate a lot more of the code automatically.
Creating the Main Application Class
Right-click the HelloWorld project icon in the Package Explorer, and from the pop-up menu, select New ➤ Class. In the dialog, type the following values:
NOTE: A handy shortcut throughout Eclipse, both in the New Java Class dialog and in the code editor, is to type part of the class name and then press Ctrl+space to get a list of class suggestions.For example, to automatically get the class name net. rim. device. api. ui. UiApplication in the Superclass field of the New Java Class dialog, type UiApp and press Ctrl+space. Eclipse will look for possible completions in the RIM API and in any classes you’ve created in your workspace. It also works for other Java constructs, such as method names.Under “Which method stubs would you like to create?”, make sure the first two check boxes for generating a main method and constructors are checked (the third box can be checked or not, there are no abstract methods in UiApplication, so it won’t make a difference). Everything else can be left at the default.
Creating the main application class with Eclipse
You’ll get the following source code:
There are even TODO markers where we have to write our logic. We’ll do that, but first, let’s create the main screen class.
Creating the Main Screen Class
Click New ➤ Class again (or if you right-click the package in the tree view and select New ➤ Class, you won’t have to reenter the package name). Fill in the following values:
Leave all other values as default, and click Finish to create the following source code:
Filling in the Hello World Classes
Now, we’ll fill in the logic for both of our classes as in the previous sections (the code is repeated here for your convenience).
Then, add the following code for HelloWorldMainScreen.java:
Running the Simulator
As with the JDE,the application is automatically built and deployed when we launch the simulator (in fact, with Eclipse, the Java code is compiled whenever you make any change, which makes spotting errors easy). Running the simulator involves an extra step or two, because you have to create a debug configuration. The advantage of this is that you can create multiple device configurations for different simulators and quickly select whichever one you need.Click the arrow next to the debug icon in the Eclipse toolbar, and select Debug Configurations.
The Eclipse debug configurations drop-down
The Debug Configurations dialog (see Figure) lets you set up different configurations, which may be different simulators or actual devices. Each configuration can have different debug parameters, and as you develop applications, you’ll likely end up with a few different configurations for debugging different operating system versions, screen sizes, and so on. Feel free to explore these options at any time. For now, select the BlackBerry Simulator icon on the left side, and click the New button on the toolbar in the dialog window that’s shown in Figure .
Setting up a simulator debug configuration with the Eclipse Plug-in
We’ll keep all the defaults, so just click the Debug button at the bottom of the dialog shown in Figure, and the simulator will launch with your application deployed. From this point on, you can access your debug configuration directly from the Debug dropdown menu in the main Eclipse toolbar by clicking the downward-facing arrow next to the debug icon.
The default values for a new debug configuration
Using Breakpoints and the Debug Perspective
A breakpoint can be set for a line from the Run menu, using Toggle Breakpoint. When the application stops at a breakpoint, you’ll be prompted to show the Eclipse Debug perspective. The Debug perspective gives you the same information as the JDE, arranged slightly differently.
The Eclipse Debug perspective, stopped at a breakpoint.
All the same functionality that was available in the JDE is available here, using Eclipse’s keyboard shortcuts and menus, of course. More debugging information is available from the Window menu, under Show View.
Building and Signing Your Application
The concepts are the same for building and signing with the JDE Plug-in for Eclipse as with the JDE. To build your application, open the Project menu, and click Build Active BlackBerry Configuration. To sign the application,open the BlackBerry menu, and select Request Signatures. The same dialog will appear as you saw with the JDE.
Building with Different JDE Versions
Building with different versions of the JDE using the JDE Plug-in is accomplished by changing your workspace configuration. By default, the JDE Plug-in comes with a single version of the JDE; you must download others as outlined in Chapter 1. The easiest way to access your JDE configuration is by clicking Configure BlackBerry Workspace from the BlackBerry menu. You’ll be presented with the Eclipse Preferences window, opened to the BlackBerry JDE section. This window is worth exploring a bit on your own time, but for now, click the Installed Components item in the left-hand tree view.
Changing JDE Versions in Eclipse
You’ll see a list of all of your installed JDE versions. Select one, and click OK. You’ll be prompted to rebuild your workspace with the new JDE version.
NOTE: You can only run debug configurations corresponding to your currently selected JDE version. Others will still show up in the debug drop-down, however. Selecting an incompatible one won’t cause any harm but will result in an error dialog.
Debugging on a Device
Like the JDE, the JDE Plug-in allows you to debug code on a real device. This requires the creation of a new debug configuration. From the Debug toolbar menu, select Debug Configurations, and create a new BlackBerry Device configuration by highlighting that icon and clicking the New button.
Setting up for on-device debugging using the Eclipse Plug-in
BLACKBERRY Related Interview Questions
|J2ME Interview Questions||BLACKBERRY Interview Questions|
|Android Interview Questions||Retail Interview Questions|
|Telecommunication Project Management Interview Questions||Mobile Testing Interview Questions|
|Telemarketing Interview Questions||Mobile Application Testing Interview Questions|
|Mobile Marketing Interview Questions||Telecom Billing Interview Questions|
|Mobile Application Architect Interview Questions|
Setting The Stage
What Makes A Blackberry Application?
User Interface Basics
Beyond The Basics Of User Interfaces
Hello Out There! Making A Network-enabled Application
Where Am I? Using Location-based Services
Getting Your App Out There: Packaging And Publishing
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.