03-26-2009 09:44 AM
I am trying to include a jar into my application using the Eclipse plugin. I have looked around the forums and so far I've gotten mixed messages. On one hand, there's a KB referring to adding a jar into an application here:
The originating thread (http://supportforums.blackberry.com/rim/board/mess
Personally, I've been able to link the jar into my application in Eclipse (make the jar its own project and have a project dependency on it) and have the simulator successfully recognize that both projects/modules are present. However, once I create the cod file for my application and load it onto my handset (via javaloader command line method), the dependent project was not carried over. It seems like the simulator just starts up both "projects" but doesn't really associate them in the cod file.
Solved! Go to Solution.
03-27-2009 06:38 AM
I don't have an answer for you but have a workaround.
Basically you can continue to use eclipse and dependent projects for IDE development.
Then I create ant build files for my projects via http://bb-ant-tools.sourceforge.net/
and compile all the dependent cod files into the main ones.
03-27-2009 08:53 AM
When you are loading the app ino your device, you must also load the jar file which is comiled by Eclipse. Generate .alx files for both - you application and the jar library . When compiling the code in Eclipse, make sure that the option "Activate For Blackberry" is selected for both the application and the jar library. Using Desktop manager , load both the alx files to your device. Your applicaion should work now.
03-30-2009 10:29 AM
@gibli: Thanks for the suggestion. I've looked around and it seems like bb-ant-tools may have a work around. I'll take a closer look.
@subash: I'm actually trying to it place it all into one codfile because I'm trying to place the file on a web server to get it delivered OTA. I'd rather not have to manage two different alx files and require both to be installed for my main application to work.
From what I hear, this feature is not available in the last release of the Eclipse plug-in. I'm wondering if RIM will fix this in the next release of the Eclipse plug-in. Not being able to place jars into cod files is a huge disadvantage to developing with Eclipse (I've got other non-BlackBerry projects to work on, that's why I like a central IDE). Until now, the BlackBerry Eclipse plug-in has been fantastic and creates all the necessary files without hassle (cod files, jad file, etc.)
04-10-2009 09:36 AM
04-13-2009 10:30 AM
This 3rd party jar is a Utility package that I'd like to use. It's been built in-house so luckily, I could just take the source code and incorporate it into my project. This, however, is not always the case since I may just have the class files in the jar (the jar wasn't built using a BlackBerry project, it is strictly just a bunch of classes that I'd like to import). I am currently using the gold release (184.108.40.206) that you're referring to.
I've tried the following methods:
1) Created new BB project. Set as Library project. Under libraries, added the external jar (ExternalJar.jar). In main project, went to the Java Build Path and added the Library project as a required project. There are still build errors in the main project (Cannot pull in the external jar from the library project).
2) Created new BB project. Set as Library project. Put in all the source code into the project. In main project, went to the Java Build Patha dn added the Library project as a required project. The main project compiles properly (recognizes the link between the two projects). Works in the BB simulator (since both projects are active configs). I then need to load both jad and cod files (I do doing these through a web server for OTA) onto the device before they work. If I try to just download the main project, the jad file says that the Library project has not been installed. So I need to install the library cod file onto the device first before I can download the main project's cod file.
The second seems to be the way that you are referring to. The problem with that is the jad/cod file of the main project cannot be installed until the library's jad/cod file is installed. Is there a way to make it just one jad file (a generated one instead of a manually created jad file) to bring both cod files in?
Also the latter only works if I have the source code, but I can't seem to get it to work without the source code, just class files in an external jar. Why can't an external jar be added as a library of the main project so that when the cod file is created, it is just added as part of the cod file? How do I get just an external jar to be part of a project?
04-22-2009 11:57 AM
The library JAR file needs to be added to the project itself in order to be built into a COD file.
You can install both the library COD file and application COD file at the same time. You can use the updatejar command line tool to combine the two JAD files ino one. This tool is included with the BlackBerry JDE and BlackBerry JDE Plug-in for Eclipse (in the bin directory).
In case you'd like to hand craft the JAD, have a look at the following links. Juse ensure that you list the library file first so that it is installed before your application.
06-10-2009 02:37 PM
I have tried both, using the UpdateJar.exe and also manually changing the JAD file to include the other COD file. Both methods fail with "907 invalid cod network error" message. I was not able to look at the links you provided, looks like they are not available anymore.
Here is my updated JAD file: KS2 is the cod file I am trying to load before the application is installed:
Manifest-Version: 1.0 RIM-COD-Module-Name: ShopAssistMobile RIM-COD-Module-Dependencies: net_rim_cldc,KS2 MIDlet-Jar-Size: 117115 MIDlet-1: ,, RIM-COD-Creation-Time: 1244608879 MIDlet-Jar-URL: ShopAssistMobile.jar RIM-COD-URL: KS2.cod RIM-Library-Flags: 2 RIM-COD-SHA1: eb d4 ef 1e 96 da 39 d7 79 f0 3f d1 91 7d 7a 78 5d 31 04 ad RIM-COD-Size: 34576 RIM-COD-URL: ShopAssistMobile.cod RIM-COD-SHA1: 2c 5e f2 9b 0a c0 24 b3 0b 69 6a ac 58 11 de 64 3c b5 73 f3 RIM-COD-Size: 48752 MicroEdition-Configuration: CLDC-1.1 MIDlet-Version: 1.0 MIDlet-Name: ShopAssistMobile MIDlet-Vendor: Dragnev Software Solutions LLC MicroEdition-Profile: MIDP-2.0 RIM-MIDlet-Flags-1: 0
On the server, I have ShopAssistMobile.cod, ShopAssistMobile.jad, ShopAssistMobile.jar, KS2.jar, KS2.jad, and KS2.cod available in the same directory from which the user will download them.
If I install KS2.jad first and then ShopAssistMobile.jad (the original, without the 4 lines that reference KS2, the bolded text above) everything loads correctly, so I know the individual COD files are working without errors.
I am developing using Eclipse (4.5) and am trying to upload to BlackBerry 8300 Simulator.
Thank you for your help,
06-10-2009 11:53 PM - edited 06-10-2009 11:59 PM
To answer my own question: the mistake I was making was that I was not specifying the COD files in the form RIM-COD-URL-#. After rewriting the JAD file accordingly, everything worked well. Here is a quick example provided by Eric Giguere.
MIDlet-Name: My Silly App
MIDlet-Description: Wish it would do something
MIDlet-Vendor: RIM Should Buy Us For Big Bucks, Inc.
Hope that helps.
01-21-2010 08:51 AM
Cant the lib be statically linked into a single .cod ?
1st I imported an external jar in the build panel, the application compiled fine
Exporting the lib does not seems to have effect (last panel in build option)
So I added the *.jar as an external source into my application project...
but it seems to cause trouble at compilation, it complains that code is not invoqued and on execution an exception is thrown : "java.lang.NoClassDefFoundError" ...
Note that I managed to make it working by installing 2 cod's ...