Blackberry Java Development Environment (JDE)

The Blackberry Java Development Environment, found here, is a pretty interetsting tool to work with.  I mean, we’re all spoiled with the likes of Netbeans, Eclipse, and those other IDEs that try to make life as candy as possible.  So, I see a lot of ranting about JDE in the J2ME community.  Jeez.  I mean, I grew up programming on DOS command lines for chrissake.  So, what are you complaining about?

Perhaps it’s fate, luck or whatever, but I typically end up dealing with the JDE issues that aren’t documented very well.  And by issues, I mean the issues and information the typical developer won’t run into or have reason to investigate.  What the blazes does the pattern-recognized command line argument tell you anyway?  Can’t find that documented anywhere…

So, like so many pages on my blog, it’s out of necessity that I put this information here about the JDE.  Hope you find it useful, especially if you’re just starting out with JDE.

Using JDE, means you’re gonna go old school …

If you’re pulling your hair out trying to make JDE work for you, you’re not alone.  You’re going to have to do some things you’ve been doing a while manually, or find new ways of doing old things.  It’s frustrating to figure out if you’re not used to it.

But remember, the people at RIM are providing the toolkit for free, and for what it’s worth it works as advertised.  Much  to RIM’s credit, they’ve provided you with all the tools you need to develop any kind of Blackberry application.  So, there’s only so much whining allowed.

That said, JDE isn’t for the faint at heart.  Some non-features you can expect to see (and what I talk about in this page):

  • you can’t import source code files into a project en-masse.
  • more coming as they pop up…. like pattern-recognized.

Import Source Code En-Masse

You’ve got lots of source code.  You want to use JDE to build a project for your Blackberry.  Being the astute developer you are, you decide to add all your source code files to a JDE project.  So, you stumble through the process of creating a workspace, then a project within the workspace.  Finally, after about two hours just getting familiar with that, you try to add your source code to the project.  Cuss words come out of your mouth as you realize you can only import one file at a time, and each import requires you to :

  1. right-click the project name (or just select it and press Insert) -> Add File To Project … -> (pick your file)
  2. repeat process for each file in your project.

It won’t take long for you to realize you’re a sadist if you do this for every file in your project.

Solution: stop doing that.

Instead, create a library project in JDE that contains one or more .jar files, and set your main project to view the library project as a dependency.  Then, once you create, build and sign a library project, you’re going to upload it to the Blackberry as a installed package/application.  Get the picture?

Example.  Let’s say you’ve got a project called MyProject you’re building, and you want to import an existing .jar file called

My-Jar-File-With-An-Open-Source-Library-That-I-Can-Resell-
To-Unsuspecting-Clients-Without-Paying-The-Author-A-Dime.jar

Don’t laugh … you know it happens. Fine, just call it MyJarFile.jar.  Try this:

  1. Build your jar file (MyJarFile.jar) using your favorite IDE.  I use Netbeans, because, well … I’m used to it and I’m older than most of you programmers and I’m set in my ways.  So, there.  Don’t want to use that? Then use the vi editor like I do.  It’s good for you.It doesn’t matter, either, if you create a MIDP application, a MIDP library, or if you built your code by hand using something like Ant or Maven.  Just produce a .jar file (MyJarFile.jar, in this case).  Don’t argue.
  2. Don’t worry about signing MyJarFile.jar.  Accept it as it is.  It’s one of the earth’s newly born creatures.
  3. In JDE, create a new project called MyLibrary in your workspace.  Designate the project a library. It’s important.
  4. Add the jar file to the MyLibrary project.  Go to the directory where MyJarFile.jar is located.  You won’t see the .jar file listed in the dialouge though, because the file filter on the dialoge box doesnt give you .jar as a choice.  So, break some rules and choose “Show all files.”  Just because .jar isn’t in the dialoge box, doesn’t mean JDE won’t be able to read it properly.  Shame on JDE for not showing .jar as an option.  Bad JDE.  Bad.
  5. Select MyJarFile.jar and click “OK”.  The file will pop into your MyLibrary project.
  6. Create the .alx file for MyLibrary, build the application, and then request signatures.  You’ll see MyLibrary.jar built, and the contents of MyJarFile.jar will be copied into MyLibrary.jar.  A .cod file for MyLibrary will also have been created.
  7. In the JDE project for MyProject, make that project dependent upon MyLibrary.  Write some source code that depends upon MyLibrary in MyProject.  Do that now.I’m waiting …… waiting…
  8. O.K., now that that’s done, build the application, generate the .alx file, and sign it.
  9. Start up Blackberry Desktop manager and upload both cod files you just created.  One for MyLibrary and another for MyProject.  Since MyLibrary is a … ahem … library, the Blackberry won’t choke when you upload it, and it won’t display an icon for your library on the phone.  It’s just stored in memory sonwehere (no … don’t ask me where ’cause I don’t know).I mentioned MyLibrary had to be designated a library in JDE, didn’t I?If you absoutely must upload one file at a time, then upload MyLibrary first.

You can also read these instructions in more detail here: http://www.blackberryforums.com/developer-forum/33039-import-external-jar-files-jde.html

(c) 2008 Richard Schilling.  If I find this printed elsewhere I’ll send a nasty letter.  Do not distribute.

4 thoughts on “Blackberry Java Development Environment (JDE)

  1. To include the library with the main jad and cods See:-

    http://supportforums.blackberry.com/t5/Java-Development/How-to-make-a-jad-file-include-dependencies/m-p/176969

    You can use the updatejad command line tool included with the BlackBerry JDE to add your library JAD file entries into your main application JAD. This tool is located in the bin directory of your installation directory. You can also read more about JAD files here:

    http://na.blackberry.com/eng/deliverables/5820/Wireless_pull_user-initiated_447306_11.jsp

    http://na.blackberry.com/eng/deliverables/5820/Attributes_for_jad_files_513047_11.jsp

  2. But how do you package both the Library and the entry code into a single unit for distribution? That’s an important step for any commercial product.

  3. Great article – thanks. I came across a gotcha using the RIM Blackberry JDE which might save other some pain – the MyJarFile.jar must be built in the IDE as a Midlet (project type Midlet in properties) and not as a Library which I foolishly did and wasted a whole afternoon with trying to hunt down why I couldn’t sign the final library cod (got RIMAPPSA2 signature needed….)

    Step 3 above is correct – its the original project that you use to build the jar that must not have its type set to Library……

  4. Pingback: Update: 22 SEP 2008 « Richard Schilling’s Professional Weblog

And now it's your turn ... comment here or on Twitter (@Androider)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s