Supported BlackBerry devices
For supported BlackBerry devices
Setting up Eclipse development environment
These are instructions for setting up your IDE with Eclipse
Please NOTE: If at any point during this setup Eclipse tells you to restart - just do it. Ignoring that messed up a few install attempts for me (yes - I tried getting the IDE running about 3 times before it actually worked). In fact, the way I finally got the IDE set up properly was to reboot after each of a) installing Eclipse, b) installing the BB plug-in and component packs. Yeah, doesn't make sense, but it worked. You're going to love the Windows + RIM SDK combo. Another side note: the first couple of attempts I tried installing the Eclipse RIM plug-in on an install of Eclipse that had the Android plug-in installed as well. This may have been the source of some of my initial problems getting it running. I ended up installing a fresh copy of Eclipse in a different directory and dedicated it to the RIM JDEs - that seemed to work.
1. Get Eclipse 3.4 or 3.4.1 - it has to be one of these versions. http://www.eclipse.org/downloads/packages/release/ganymede/r
2. Then from this page: http://na.blackberry.com/eng/developers/javaappdev/javaeclipseplug.jsp
a) Download the 'Full Installer' and install the Eclipse plug-in.
b) Download the 'Eclipse Software Update for the BlackBerry JDE v4.6.1 Component Pack' (should be an archive).
c) Download the 'Eclipse Software Update for the BlackBerry JDE v4.7 Component Pack' (again, archive).
3. After the full installer installs the BB IDE plugin, load up Eclipse. (if you already tried this and failed and are installing again, then reboot before loading Eclipse up. Yeah, I know. It sucks. Just reboot.).
4. In Eclipse, go to Help -> Software updates. Click on Available Software tab, click on Add Sites, click on Archive, point the browser to the two component packs you downloaded (4.6.1 and 4.7). These are the only versions of the BlackBerry JDE that the proper browser rendering option works on (not entirely true: JDE version 5 also has it, but it is still in beta at this time). NB: On some installations, instead of clicking on 'Archive' after 'Add Sites', you actually have to extract the component pack archives you downloaded from RIM and click on 'Local...' instead of 'Archive...' and point the file browser to the extracted folder. This seemed to be an issue on a virtual install of Windows XP on a Mac.
5. In Eclipse, there's a Blackberry menu - hit that and click on 'Configure Blackberry Workspace.'
6. You should see 'Blackberry JDE' in the side menu and a whole bunch of sub-menus:
a) Blackberry Workspace page: enter '1' for version (or some other number) and something for the Vendor field.
b) Code Signing page: Check every option. Only really necessary for debugging - you probably won't want to have everything checked for an App World release, as that will force you to get additional code signing keys on top of the stock RIM ones (for the extra cryptography API, at least).
c) Installed Components page: Select either 4.6.1 or 4.7 (assuming the component packs you downloaded installed successfully). I usually play around in 4.7 because it is newer, but 4.6.1 should work too. NB: Even though at the time of writing this tutorial we still do not have support for Accelerometer, it looks like 4.7 has support for an Accelerometer sensor listener, whereas 4.6.1 does not. Keep that in mind.
7. Hit apply, that should rebuild your Eclipse workspace.
8. Finally, one last step: once you have a project going, before deploying/testing on the emulator you need to right-click on the project and make sure 'Activate for Blackberry' is checked. If you don't do this, then your application won't show up in the Downloads folder on the emulator/device.
One more thing: if you're testing an app that's using internet / needs connectivity make sure your run the 'MDS-CS' app - it proxies HTTP requests/responses for the emulator. You can find it in Start Menu -> Programs -> Research In Motion -> {JDE Version You're Using} -> MDS-CS
After you run it (either in the emulator or on the device), the application should show up under the Applications menu -> Downloads.
Mac OS X
If you are running Mac OS X using Vmware (tested with XP installed), then steps 2-4 should be replaced with the following:
2. Setup the Blackberry Software Update Site
a) Select Software Updates…
b) Select the Available Software tab
c) Click the Add Site… button
d) In the Add Site dialog, type the URL http://www.blackberry.com/go/eclipseUpdate into the location text box
e) Click the OK button, BlackBerry Update Site appears in the Available Software list
3. Under the Available Software tab (Software Updates), check the Blackberry JDE Plugin under Blackberry Update Site, and install, then allow it to restart eclipse.
4. Reopen the Software Updates, and again navigate to the Blackberry Update Site, and select and install Component Pack 4.6.1, and allow it to restart eclipse. Then do the same for Component Pack 4.7. Do these two installs separately.
4.5. Create a new BlackBerry project to initialize the BlackBerry workspace.
- Open the File menu and select New -> Project
- Select BlackBerry Project from the available Wizards and click Next
- Name the project something arbitrary, such as 'test' or 'dummy' and click Finish
- This project can be deleted after creation
If any part of this fails, reinstall eclipse and start over. It's windows.
Random Errors
If you're having trouble getting your application running, and are receiving cryptic error messages and/or error messages with no title/content (yeah, that's happened to me before), try clearing your emulator environment. From Eclipse, BlackBerry menu -> Erase Simulator File -> Erase All. This has fixed random environment/debugging errors for me before. Good luck!
Comments (32)
Nik said
at 7:08 am on Feb 16, 2009
For anyone looking for the url for step 2, its http://www.json.org/java/org.json.me.zip
Nik said
at 1:46 pm on Feb 20, 2009
I immediately get an "illegal state exception" when running this... any ideas? Thanks.
Dave Johnson said
at 11:24 pm on Feb 20, 2009
I don't recall ever seeing that error Nik ... any other clues you have?
Nik said
at 9:23 am on Feb 21, 2009
Hi Dave,
Yes - it appears to be throwing it when processing the title of the document. See stack trace below. I've commented that bit out in the meantime, and its running, so I'm encouraged.
Currently fighting the rubbish built in browser to try and make an app that's worth using :-\
Thread [phonegap(188)id=1429553152] (Suspended (exception IllegalStateException))
UiEngineImpl.assertHaveEventLock() line: 3404
VerticalFieldManager(Field).assertHaveEventLock() line: 5699
VerticalFieldManager(Field).applyTheme() line: 993
VerticalFieldManager(Manager).applyTheme() line: 481
TitleStatusManager(Manager).insertInternal(Field, int) line: 1775
TitleStatusManager.setTitle(Field) line: 874
TitleStatusManager.setTitle(String) line: 889
MainScreen.setTitle(String) line: 469
PhoneGap.eventOccurred(Event) line: 158
HTMLBrowserContent.setTitle(String) line: 271
HTMLTitle.setText(String) line: 37
RHTMLRenderer(HTMLBaseRenderer).handleAccumulatingObject(String) line: 2890
RHTMLRenderer(HTMLBaseRenderer).characters(String) line: 2924
RHTMLRenderer.parseData() line: 572
RHTMLRenderer(HTMLBaseRenderer).finishProcessingData() line: 854
HTMLBrowserContent(BrowserContentImpl).finishLoading() line: 694
HTMLBrowserContent.finishLoading() line: 463
BrowserContentManager.handleNewContent() line: 93
BrowserContentManager.setContent(HttpConnection, RenderingApplication, Event) line: 57
PhoneGap.processConnection(HttpConnection, Event) line: 115
PrimaryResourceFetchThread.run() line: 703
Dave Johnson said
at 11:13 am on Feb 26, 2009
That's strange. I would be keen to see if you can build an app worth using in that browser :)
I am hoping that the next bold / storm will have it updated so that I can get back to working on BlackBerry.
Ave Wrigley said
at 5:48 am on Mar 4, 2009
URL for 1) is http://na.blackberry.com/eng/developers/javaappdev/javaeclipseplug.jsp
Ave Wrigley said
at 9:18 am on Mar 4, 2009
I have got this working on the emulator - any ideas how to change the app name / icon?
Chuck Brandt said
at 9:24 am on Mar 17, 2009
I'm questioning what to do at step 9. Is that html file available somewhere for download? I have the app running in JDE but just get a white screen.
Chuck Brandt said
at 8:52 am on Mar 18, 2009
I am now getting the IllegalStateException as described by Nik above. Could someone spell out the specific work around for this? Thanks :)
Nik said
at 9:27 am on Mar 18, 2009
Here's the hack I did :
case Event.EVENT_BROWSER_CONTENT_CHANGED: {
// browser field title might have changed update title
BrowserContentChangedEvent browserContentChangedEvent = (BrowserContentChangedEvent) event;
if (browserContentChangedEvent.getSource() instanceof BrowserContent) {
BrowserContent browserField = (BrowserContent) browserContentChangedEvent.getSource();
String newTitle = browserField.getTitle();
if (newTitle != null) {
//Nik - removed this bit
//_mainScreen.setTitle(newTitle);
}
}
break;
}
Egor Nechiporenko said
at 6:26 am on Mar 30, 2009
Can somebody put working examples of using phonegap in BlackBerry... I have the same problems as Chuck Brandt.
I have the app running in JDE but just get a white screen. Where should i put my html file?
Praveen said
at 12:48 pm on Mar 31, 2009
According to the documentation.
There are two ways for background threads to access the UI from outside the main event-handling or UI drawing code:
* acquire and hold the event lock
* use invokeLater() or invokeAndWait() to run on the event dispatch thread
so I used the following fix:
synchronized(this.getEventLock()) {
_browserContentManager.setContent(connection, this, e);
System.out.println("The content of the web page has been set.");
}
IT worked for me.
Egor Nechiporenko said
at 6:24 am on Apr 3, 2009
I cannot realy understand, has somebody created a correct PhoneGap BB application using new JDE, unfortunantly there are no examples ow working applications.
But I am new in Blackberry developing, so now i can`t understand how to resolve exceptions in PhoneGap application(
Praveen said
at 12:14 pm on Apr 3, 2009
Hi Egor,
If you can post the error that u have got. We can assist you.
Yes.. PhoneGap is working properly for me with the above fix that I mentioned in the previous comment.
Post the difficulties you are facing to help you out.
cya
Muhammad Mohsin Ali said
at 5:50 am on Apr 8, 2009
Are there other tutorials on developing BlackBerry apps using PhoneGap?
Arun Yadav said
at 7:24 am on Apr 9, 2009
Hi could anyone help me in step5 and step6. Should I paste the whole extracted phonegap folder or just some selected folder and in which folder of phonegap project(main folder or under src or somewhere else, I would really appreciate if someone could help me.
Muhammad Mohsin Ali said
at 10:05 pm on Apr 9, 2009
Step5: Copy all the extracted files and folders.
5.1: Goto your eclipse project->src and paste here.
Step6: Copy "org" folder.
6.1: Goto your eclipse project and paste here.
Muhammad Mohsin Ali said
at 10:58 pm on Apr 9, 2009
Step9: ??
in PhoneGap.java "_url = htttp://..."
Wot would be the url?
Arun Yadav said
at 7:04 am on Apr 14, 2009
Its not working, cud anyone please explain me how to proceed after step 4?
Thank you.
Egor Nechiporenko said
at 11:07 am on Apr 14, 2009
I wonder if it possible to use as _url "http://localhost". And where should i put folder "/www" (in blackbery device and in file system for simulator), if i want to use _url="http://localhost/www/index.htm"
kashif said
at 5:56 am on Apr 15, 2009
Hi everyone,
Is phonegap is stable enough to use it in professional applications or it is still in the building process?
Actually I've to develop a mobile version of a web application that could ideally run on Blackberry, iphone, Android etc. So i am in decision making process weather to go for phonegap or develop separately for blackbery, iphone ...
Any comments....
Look forward for suggestion!
Cheers !
Ali Sleiman said
at 6:26 am on Apr 15, 2009
Can you please post the steps you took to create this web application you created and possibly post a sample. I am interested in knowing the details.
Egor Nechiporenko said
at 9:22 am on Apr 23, 2009
YES!!! I`VE Done this. There are a possibility how to browse local pages in Phonegap application.
There are a few steps to do this:
1) You must include all html, css pages and images to your project in special folder. I created folder www and put all items there.
To check that all files included you can, in file PhoneGap.jdp. Just open it in NotePad. There must be text like this:
[Files
www\aclu_logo.png
www\Donations_Religion.html
www\Icon.png
www\index.html
www\Non-Citizens.html - files you want to include
www\Questioning.html
www\Stops_Arrests.html
www\style.css
]
2) Change file Utilities Java:
public static HttpConnection makeConnection(String url, HttpHeaders requestHeaders, byte[] postData) {
HttpConnection conn = null;
OutputStream out = null;
String newUrl;
try
{
if ( url.indexOf("data://") != -1)
url = url.substring(url.lastIndexOf('/') + 1);
if ( url.indexOf("http://") == -1)
url = "/www/".concat(url);
InputStream input = Application.class.getResourceAsStream(url);
if (input == null)
System.out.println("Cannot connect to page ".concat(url));
DataBuffer buffer = new DataBuffer();
byte[] temp = new byte[ 1024 ];
for( ;; )
{
int bytesRead = input.read( temp );
if( bytesRead == -1 )
{ break;}
buffer.write( temp, 0, bytesRead );
}
ByteArrayOutputStream output = new ByteArrayOutputStream();
Base64OutputStream boutput = new Base64OutputStream( output );
output.write( "data:text/html;base64,".getBytes() );
boutput.write( buffer.getArray() );
boutput.flush();
boutput.close();
output.flush();
output.close();
newUrl = output.toString();
url = newUrl;
}
catch (Exception E){
}
After that, when change value _url to ="index.html". Program will try to open file www/index.html
Zia Ul Huda said
at 11:28 pm on Apr 23, 2009
Hi all
I have been trying to get the geo location using phonegap in Blackberry simulator for last two days but no success. I tried the example given on iphone page for geolocation but comes up with error that GAP is not supported. More analysis give that __gap variable used in gap.js file is not defined. I cannot find any definition of that variable in any of js files.
I also tried to use geolocation.js file directly and called Geolocation.prototype.getCurrentPosition method directly but in there it says that phonegap is not defined on line 2 as follows
document.cookie = 'bb_command={command:'+phonegap.LOCATION+'}';
So any help or a working example for using geolocation on blackberry is much appreciated.
Thank you.
digitalkev said
at 6:09 am on May 19, 2009
hola
I've been trying to install phonegap but dont know whats going wrong.
When i hit run on elcipse, the simulator runs but i dont see the application. I dont see any errors neither... I dont see any compiler message ...
I checked my path variable i have the jdk on first entry, i followed the instructions given in here with no success.
Two weeks ago when I started working with the blackberrys I thought the hardest thing was going to be learning the Java language, but I see that the complication is with the JDEs.
Please help, Thanks,
wilmer Abreu said
at 2:19 pm on May 22, 2009
I am beginning to phonegap using the source code for blackberry set everything as indicated in the manual but when I try to run in the emulator displays this error (unable to start simulator. Check that the file exist. (Java.io.IOException: ... ....) what is MDS proxy .... why i need that to run my apps ?
wilmer Abreu said
at 7:08 am on Jun 2, 2009
wow 2 weeks and any answers
AJ said
at 4:10 pm on Jul 27, 2009
Is this Blackberry project active? Followed the instructions but haven't been able to run this sample.
Brian said
at 8:30 am on Nov 16, 2009
Wilmer,
you need MDS running on the simulator so that you can actually browse the web (I use it to call my webservice). I'm not sure what will happen once deployed to a device, I'm hoping it wont be needed, well really I'm just hoping it works...
Has anyone tried to call a .Net webservice (.asmx) in order to get data?
I'm getting a pretty weird return of my simple service (here is what my service returns):
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://tempuri.org/">Hello World</string>
And this is what the NetworkCommand.java code does to it:
\u0003\u0001j string\u0000xmlns\u0000X-RIM-TBL:AAAAAA==\u0000Ä\u0000\u0004\u0007\u0003http://tempuri.org/\u0000\u0001\u0003Hello World\u0000\u0001
I'm not sure how to parse that string, I try and treat it like XML, but when I do that all my calls (using jquery) come back empty.
Anyone get this phoneGap BB working with webservices?
Fil Maj said
at 10:17 am on Nov 16, 2009
Brian,
I will follow up with you in more detail via mail, but a few answers to some of your questions are worth noting on the wiki.
BlackBerries communicate with the internet in a variety of ways. The native BlackBerry browser uses its own specific network route/protocol (can't remember exactly what it's called - BlackBerry Internet Service, I think?). PhoneGap applications use direct TCP/IP connections (or at least this type of connection is opened up). In some cases, all requests and responses go through a RIM 'gateway' server, where some transcoding of the HTTP data is done. Check this KB article out: http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/Support_-_HTTP_transmits_incorrectly_when_User-Agent_includes__BlackBerry_.html?nodeid=1367249&vernum=0 . It suggests two things: 1) remove 'BlackBerry' from the user-agent string in the HTTP request header and 2) Add another RIM-specific header to inform the RIM gateway server not to do any transcoding of the data (bottom of the article). I think the second suggestion should help out, and I'll also add it to the BlackBerry code base. I haven't encountered this particular problem before, but with so many devices and so many forms of communication on the phone (also corporate vs. regular phones), there are a lot of little things to work out.
Secondly, and maybe more importantly, in my experience jQuery *will not work* with BlackBerry OS v4.7 and below. Once the newly-announced WebKit browser becomes standard in BlackBerries (which was released announced at the BlackBerry Developer Conference), I am hoping this problem will go away.
Brian said
at 10:56 am on Nov 16, 2009
Fil, thanks for the info!..I'm going to read the KB article now...interesting about jquery as I'm able to use it (via the simulator) running 4.7 and 4.6...can't wait for 5.0!
Fil Maj said
at 10:59 am on Nov 16, 2009
Brian, if you can, test it out on a device - there's a big gap between simulator and the device, for all mobile platforms!
You don't have permission to comment on this page.