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 :
- right-click the project name (or just select it and press Insert) -> Add File To Project … -> (pick your file)
- 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
Don’t laugh … you know it happens. Fine, just call it MyJarFile.jar. Try this:
- 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.
- Don’t worry about signing MyJarFile.jar. Accept it as it is. It’s one of the earth’s newly born creatures.
- In JDE, create a new project called MyLibrary in your workspace. Designate the project a library. It’s important.
- 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.
- Select MyJarFile.jar and click “OK”. The file will pop into your MyLibrary project.
- 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.
- 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…
- O.K., now that that’s done, build the application, generate the .alx file, and sign it.
- 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