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
Contributor
Posts: 13
Registered: ‎02-20-2010
My Device: Bold 9700
My Carrier: Rogers

Import app jar to make library project for unit testing.

Hi All,

  I've been trying to get some unit testing setup for my app using j2meunit and the fine work by Derek:

 

Unit Testing

(some great examples to work from up there, and he makes all of his code freely available, BSD licensed...what a guy!!!)

 

I haven't gone through dereks own App code, but it appears to be setup as a GUI App/front end, built against a library that has all the meat&potatos.  So, it looks like his j2meunit setup just links in the library, and drives tests against that.

 

My problme is I currently don't have that GUI+Library separation.  All my code is in the one project.  So I was not able to import my app as a dependency for my TestApp app.  I was all set to start refactoring to have a GUI+Library design, but then started finding links for how to import a jar into a library project to make it available for import.

 

How To - Compile a jar file into a BlackBerry Library

 

So I tried what is talked about in that thread but its not working.  At the moment it doesn't seem like my library is building (no jad/jar).  The Eclipse error I have is:

 

"Project {0} has to have a jad file file if it exports a mildlet jar."

 

Here's my question... either:

 

A) Am I using this technique correctly.  Can I take my App jar, bring it into a library project, then import into another app?  if so...

B) What could be going wrong here?

 

I have more details on thigns I've tried, but I'm already going a bit too long here.

 

Thanks in advance.


Stu

Highlighted
Developer
Posts: 41
Registered: ‎08-05-2008
My Device: Not Specified

Re: Import app jar to make library project for unit testing.

If you use JDE its easy to make library from jar file, just create a new library project & add the jar file to project. you can use this library project as dependency in other projects.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Import app jar to make library project for unit testing.

There is an alternative in the JDE too.  In a project you can define jars that are imported at build time.  You just need to import your jar.

 

However you still have to do the suggestion below which will provide you with a way to create a cod, which you will then have to manually put on the device/simulator.

 

I prefer the jar/build approach to the straight library approach, because then I don't actually include the library project into all the workspaces.

 

Sorry not a very good explanation and you are probably using Eclipse and I don't know if you can do the same in Eclipse. 

Contributor
Posts: 13
Registered: ‎02-20-2010
My Device: Bold 9700
My Carrier: Rogers

Re: Import app jar to make library project for unit testing.

Hey Guys,

  Thanks for the replies.  I am indeed using Eclipse.  I haven't tried the RIM JDEs since I was last developing 2 years ago, but comparing my experience now with the Eclipse plugin, and what I remember of RIM JDE, eclipse is a real treat.

 

But I'm getting the impression from both of you, and from other posts on the board, that the JDE is my best bet to make this work.  Its too bad.  It seems like I'm EVER so close to having it work in Eclipse.  I wish I understood what was going wrong.  Any ideas what the problem with eclipse is?

 

On th eother hand, my app is still small, so refactoring to a lib/GUI separation wouldnt' be hard.

 

Regular Contributor
Posts: 67
Registered: ‎09-30-2009
My Device: Not Specified

Re: Import app jar to make library project for unit testing.

I also had a "Project {0} has to have a jad file file if it exports a mildlet jar." problem after using the "Export and Order" with my Blackberry lib jar. Removing the jar from exported solved the problem.

I had however to copy the lib *.cod, *.cso, *csl and *.debug files to simulator folder in order to run the application that depended on the lib successfully.

New Developer
New Developer
Posts: 151
Registered: ‎01-05-2010
My Device: dev alpha c (bb10)
My Carrier: www.rzr.online.fr

Re: Import app jar to make library project for unit testing.

How To - Compile a jar file into a BlackBerry Library

 

is at this url :

 

blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800901/How_To_-_Compile_a_JAR_file_into_a_BlackBerry_Library.html ?nodeid=801017&vernum=0

 

and how to create one :

 

http://blackberry-tips-bikas.blogspot.com/2010/02/how-to-create-library-jar-file-and-use.html

 

but this my be obsolete now , but i havent figure out to do it the "eclipse way"

 

it fail to link it :

 

http://supportforums.blackberry.com/t5/Java-Development/Could-not-run-the-ultralitej-sample-project-...

 

 

regards