1. 安装BlackBerry_Email_MDS_4.1.4.exe和BlackBerry_Simulators_5.0.0.228_9700.exe
2. 安装eclipse3.6
3. 安装BlackBerry Java Plug-in for Eclipse v1.1
4. 创建BlackBerry工程,File -> New -> Project -> BlackBerry -> BlackBerry Project
Project name: HelloWorld
Click "Finish" 完成项目创建
5. 创建一个新的java类,名称为HelloWorld,内容如下:
import net.rim.device.api.ui.Field;import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;
public class HelloWorld extends UiApplication {
public static void main(String[] args) {
HelloWorld theApp = new HelloWorld();
theApp.enterEventDispatcher();
}
public HelloWorld() {
pushScreen(new HelloWorldScreen());
}
}
final class HelloWorldScreen extends MainScreen {
HelloWorldScreen() {
super();
LabelField title = new LabelField("Hello World Title", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
add(new RichTextField("Hello World!", Field.NON_FOCUSABLE));
}
public void close() {
Dialog.alert("Goodbye!");
super.close();
}
}
6. 在BlackBerry的模拟器中运行HelloWorld程序
选择HelloWorld项目,右键 -> Run As -> BlackBerry Simulator
在出现的BlackBerry Simulator窗口里单击菜单按钮,然后单击Downloads图标,此时会出现刚刚新建的HelloWorld应用程序的图标,单击此HelloWorld图标就可以运行此应用程序,这个HelloWorld程序就是在应用程序窗口里显示一个HelloWorld的标签。