How to develop applications using BlackBerry in Eclipse

Source: Internet
Author: User

This article focuses on how to use Eclipse to develop BlackBerry applications, including the establishment of the basic development environment and the running of HelloWorld, test the HTTP application in the simulator and E-mail application in the simulator. I hope this article will help you gain some benefits.

Use Eclipse to develop Black Berry applications

Basic Development Environment Construction:

If you want to develop a Java application for Blackberry, you can choose between two development environments: JDE provided by RIM and JDE plug-in added by eclipse. Most Java developers should be familiar with Eclipse, so I chose Eclipse without hesitation. So I went to blackberry.com to check the documents and found that the Java Development documents are divided into Tutorials and ManualsandGuides. I found the installation method in SettingupNecessareTools, although it is for5.0beta, however, it is okay to install 4.5 as per its method.

I guess RIM's documentation seems to be based on the new version, and the JDE and Eclipse Integration Methods documented in the BlackberryJavaDevelopmentEnvironment-4.5.0-DevelopmentGuide seem no longer necessary. By the way, RIM's documents are still rough, and the content of each document is rarely repeated, but there is no link between them. It is not clear how to install anything when it comes back, so it took a while to complete the installation. Here is a summary:

◆ Download and install JDK 6u12 or a later version. I installed JDK 6u12 and later.

◆ Download and install Eclipse. I installed 3.4.1Classic, and RIM said 3.4.0 or 3.4.1. I also installed 3.5.0. I think it is okay, but some people on the Internet say that 3.5.0 is faulty, keep it conservative.

◆ Download and install JDE4.5.0. RIM suggested returning 4.3 to 4.7. I don't think it is necessary to install 4.5.

◆ Download and install BlackBerry_JDE_PluginFull_1.0.0.67

◆ Now you can develop applications for OS 4.5. If you want to develop for other versions of OS, you can download the componentpacks listed here, or add http://www.blackberry.com/go/eclipseupdateto the upgrade manager of eclipse.

Open Eclipse and click "Help"> "SoftwareUpdates"

Click "AvailableSoftware"-> "AddSite"

Now there are two options:

Enter http://www.blackberry.com/go/eclipseupdateand click “OK .pdf ". But I have never connected to this update site ......

Or click Archive, select the downloaded componentpack, and click open ". I downloaded and installed them one by one.

◆ You can configure Eclipse by clicking "Window"> "Preferences"> "General"> "Workspace ", hook "Saveautomaticallybeforebuild" to remove "Buildautomatically" and "Refreshautomatically ".

◆ Switch between ComponentPackage: click "Window"-> "Preferences"-> "BlackBerryJDE"-> "InstalledPackage ", you can select different ComponentPackage versions from the drop-down list on the right.

Run HelloWorld

RIM provides many program examples, which are similar to "eclipse \ plugins \ net. rim. eide. in the path of componentpack4.5.0 _ 4.5.0.16 \ components \ samples, we use com. rim. sample. device. helloworlddemo. helloWorldDemo to test whether the development environment is correctly installed.

◆ In Eclipse, choose "File"> "New"> "Project"> "BlackBerry"> "BlackBerryProject", and click "Next, enter a name and press "Finish"

◆ Select the New project, open "File"-> "New"-> "Class", and enter "com." in "Package. rim. samples. device. set "helloworlddemo" and "Name" to "HelloWorldDemo", and click "Finish"

◆ Copy the content of "samples \ com \ rim \ samples \ device \ helloworlddemo \ HelloWorldDemo. java" to the new file and save it. May prompt that the encoding in GBK cannot be saved. In Preferences, I changed the encoding of TextEditors and Workspace to "UTF-8)

◆ Click "Run" in the "Run" menu. The device simulator runs automatically. You can find the program you just wrote and try to Run it, "HelloWorld" should be displayed on the simulator screen ".

BlackBerry development tests HTTP applications in simulators

The device simulator provided by RIM is called Fledge. Because Fledge cannot use a mobile communication network like a real mobile phone, and thus cannot directly access the Internet, how can he use the simulator to test the HTTP application? We know that the blackberry that has activated the data service can access the HTTP website through the MDS server. Similarly, RIM also provides the MDS Simulator for the device simulator. In Eclipse, open "Window"-> "Preferences"-> "BlackBerryJDE"-> "MDSSimulator", you can see the path of the MDS simulator, and manually execute the run under this path. bat, start the device simulator, and then you can access the Internet.

You can also configure Eclipse to enable it to automatically run the MDS simulator before each Fledge startup. The configuration method is recorded in DevelopmentGuide-BlackBerryJavaPlug-inforEclipse:

◆ In Eclipse's "Run" menu, select "RunConfigurations" or "DebugConfigurations"

◆ Expand "BlackBerrySimulator"

◆ The following two options are available:

If you want to use an existing configuration, such as "DebugServer", select it

To create a new configuration, double-click "BalckBerrySimulator" and select the new configuration.

◆ Click the "Simulator" tab, click "New" in the "Profile" column, and click "OK" after a New name is configured"

◆ Choose "LanchMobileDeviceSystemConnectionService (MDS-CS) withsimulator", click "Apply"

◆ Click "Run" to Run the task.

Now, you should be able to access the Internet through the browser in the simulator.

Test the e-mail application in the simulator developed by BlackBerry

Although the device simulator can access the Internet through the MDS simulator, but it cannot use the Blackberry data service to send and receive emails, how should we test the E-mail application? RIM naturally realized this problem, so it provided us with EmailServerSimulaor, or ESS for short. The ESS and MDS simulators are provided with the JDE plug-in, similar to "eclipse \ plugins \ net. rim. eide. the position of componentpack4.5.0 _ 4.5.0.16 \ components \ ESS. manually execute load here. bat and then run. The developer guide-BlackBerrySmartphoneSimulator introduces ESS. Here I will talk about it based on my experience:

There are two modes available after the ESS starts running: Standalonemode and Connectedmode ".

◆ In Standalonemode, ESS simulates an email server and opens ports 25 and 110 to external users. It can communicate with OutlookExpress. Emails sent by OutlookExpress are directly pushed to the phone simulator Fledge, and emails sent by Fledge are also forwarded to OutlookExpress. During configuration, create an account in OutlookExpress and set the pop3 and smtp servers as localhost. You can enter the mailbox name and password as needed. You can also enter the username, mailbox name, and PIN code of ESS, as long as the format is correct, you do not have to configure the same as OutlookExpress. After the configuration, click "Lanch" to start ESS and make sure that the "Lanch" button is grayed out. Then, you can use Fledge and OutlookExpress to send an email to test whether the email address can be entered at will.

◆ In "Connectedmode", ESS simulates an email client that can receive and push emails to Fledge from an external email server. It can also receive emails from Fledge, then, the email is sent from the external email server. However, RIM seems to have forgotten to allow ESS to support smtp authentication, so I have never succeeded in this method ...... If anyone is using it, let me know.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.