Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
New Developer
Posts: 23
Registered: ‎01-01-2009
My Device: Not Specified
Accepted Solution

How to build a library for exporting as a .jar? Works if lib is of type CLDC App, but not Library

I have a project named FooLibrary inside a workspace.  And in that project is a single file which exposes a single class.  I set that project to type "Library" (project properties->Application->project type).  And build it and the world is a happy place.  Then I create a new workspace and a new project inside the work space.  I add the file FooLibrary.jar (produced by the above) to that project.  Then I add another project to this workspace, make it depend on the project that has FooLibrary.jar in it.  I add an instance of class FooLibrary in that project.  I build it and it builds.  Then when I run it, I hit a verification error 1610.  

 

Oddly enough, if instead of making FooLibrary a library, I make it of type CLDC Application (the default type).  then when I compile FooLibrary I get some warnings but otherwise absolutely everything works.

 

Am I missing something obvious here, or am I really confused about the world? 

 

As always, thanks for everything! 

 

-- Henry 

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: How to build a library for exporting as a .jar? Works if lib is of type CLDC App, but not Librar

If you take a look into jar file created by JDE you notice that it is not correct jar file to be included as library.

 

It contains *.cso *.csl and *.cod file inside.

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: How to build a library for exporting as a .jar? Works if lib is of type CLDC App, but not Librar

To look inside of jar file use WinZip application, or just rename this jar file to zip and unzip it.

 

Also you can give command in command line:

 

jar.exe -t FooLibrary.jar

 

it will list contents of this jar file on the console.

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: How to build a library for exporting as a .jar? Works if lib is of type CLDC App, but not Librar

If you want to make a library - add relevant source files to a "Library" type project in JDE and compile it to jar file.

 

After that - delete cod cso and csl file from this jar file.

 

And try to import this jar in project properties dialog.

 

 

Developer
Posts: 173
Registered: ‎06-11-2009
My Device: Not Specified

Re: How to build a library for exporting as a .jar? Works if lib is of type CLDC App, but not Librar

[ Edited ]
OK,
Can it be finalized once and forever?
I mean, how exactly to do it in the right way?
Technically (it compiles OK) there are 3 ways to add jar file to the project:
1. “Add file to Project” explicitly.
2. Import jar file on the build step: Properties->Build->”Imported jar files”
3. The way it is described in the article (http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800901/How_To_-_Compi...)
The problem I often to fight with – application icon does not appear in the ribbon!?
BTW, I did not read any explanations rather than it should be UiApplication extended,
but my main class is UiApplication extended, and I still do not see icon in the ribbon after I included/added jar to the project!
And it may happen it in all 3 cases. How come?
Next, do we really have to remove cod and sco files from that jar files manually?
Why does RIM put all this stuff there in the first place?
What’s the difference in jar files created as Library and CLDC App?
Sorry, maybe these Qs are obvious, but I see ppl keep on asking them on and on.

P.S. OK, this is definitely weird, – this thing
does work !
Moreover, this is the only thing that works (for me?).
I tried whole day lots of ways, and you now how it is frustrating to wait until BB simulator fires up,
and after that get this unexplainable error - net.rim.vm.MissingNativeError(?)
Anyway, now it is confirmed, – jar file MUST be build as CLDC Application to be able successfully attached to other (CLDC Application) project!
And you have to preverify it, of course, before adding to another project.
Thousands of Kudos to henryci
Message Edited by konic on 08-15-2009 03:46 PM
New Developer
Posts: 21
Registered: ‎03-31-2011
My Device: Developer
My Carrier: none

Re: How to build a library for exporting as a .jar? Works if lib is of type CLDC App, but not Librar

[ Edited ]

I had success when using Eclipse, by changing the type to MIDlet instead of library or CDLC.

Add the resulting JAR file to your project, remember to Export it too.

Project should compile properly without verification problems.

In case it helps, here is my stackoverflow post... http://stackoverflow.com/questions/9976940/blackberry-use-own-jar-file-in-own-project (sorry for offsite link)

www.cobiinteractive.com
www.madmob.co.za