天天看點

黑莓開發第一篇:開發環境的搭建

入手黑莓開發 ,第一步肯定是搭建環境了,黑莓提供了自己的JDE開發工具,但是個人以為十分之不友善,還是選擇eclipse插件比較好,黑莓官網的伺服器在加拿大 ,通路速度慢如蝸牛,這裡我給迅雷下載下傳位址:

http://bbsdk.csdn.net/BlackBerry_JDE_PluginFull_1.1.2.201004161203-16.exe

下載下傳之後,按照預設安裝即可

安裝好了之後 ,按照開發習慣,先寫一個helloWorld小例子,打開eclipse,點選File-new,選擇project,然後選擇blackberry project ,工程名HelloWorld,建好之後就可以編輯代碼了

public class MyApp extends UiApplication {

/**

* Entry point for application

*

* @param args

* Command line arguments (not used)

*/

public static void main(String[] args) {

// Create a new instance of the application and make the currently

// running thread the application's event dispatch thread.

MyApp theApp = new MyApp();

theApp.enterEventDispatcher();

}

/**

* Creates a new MyApp object

*/

public MyApp() {

// Push a screen onto the UI stack for rendering.

pushScreen(new HelloWorldScreen());

//new MenuCanvas();

}

}

final class HelloWorldScreen extends MainScreen {

public HelloWorldScreen(){

super();

LabelField title = new LabelField("HelloWorld", LabelField.ELLIPSIS);

setTitle(title);

add(new ButtonField("Submit"));

}

public boolean onClose() {

//Status.show("Hello World!");

Dialog.ask(Dialog.D_OK_CANCEL, "are you sure?", Dialog.NO);

System.exit(0);

return true;

}

 這樣直接在虛拟機運作就ok啦!

繼續閱讀