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

Web and WebWorks Development

Reply
New Contributor
jason_rogers
Posts: 9
Registered: ‎09-19-2011
My Device: curve 9300
Accepted Solution

Calling a third party lib/jar

I got this blackberry tutorial to work using the native code:

---
The tutorial
http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc01214.0200/doc/html/title.html


the zip to the already done tutorial :
http://www.sdn.sap.com/irj/bpx/index?rid=/webcontent/uuid/40ea4956-b95c-2e10-11b3-e68c73b2280e

---

Now that I got that running, I need to run it in WebWorks

I've managed to create all the code and plugins I need but I just can't get the last bit to work:

 

when I add the jar inside the plugin: I get the following error when I launch the app

> Error starting MyApp: Module 'MyApp' has verification error 1691 at
> offset 0ed9 (code file version 79)

when I push the jars manually: (this is how the native code app works) I get a classnotfoundexception when I try to call code form the libraries.

 

My conlcusions are :

- in the case I put the jars inside my plugin, the code is not written in a way that BBWP can compile correctly and causes errors when you launch the app. This can only be fixed by the authors of the lib.

- in the case where I push the lib on the phone, I think I'm missing something in my config to tell my webworks project to use files that are outside the project.

 

so my question is :

how do I get a blackberry webworks project to use the libs that I deployed onto the device in the same way that the blackberry eclipse plugin does?

Retired
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold

Re: Calling a third party lib/jar

Hi  jason_rogers,

 

I just want to understand exactly what you're trying here.

 

If you're trying to reference a 3rd party jar containing compiled code from within a java extension of a webworks app then this can be accomplished. What you must do first is pre-verify the jar using preverify.exe which can be found in the bin folder. Then simply have the compiled jar in the same folder of your java source and everything should work.

 

If you're trying to use a library application this is slightly more complicated, but likely we can accomplish it, worst case it can be hacked into the source generated from the packager with the -s parameter.



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
New Contributor
jason_rogers
Posts: 9
Registered: ‎09-19-2011
My Device: curve 9300

Re: Calling a third party lib/jar

Hi Jeffheifetz

 

first thanks for your answering, I've been trying to get this to work without any certainty that it will work at all lol.

 

I'll try to make my problem clearer, I have 3 libraries provided by Sybase that belong to their client API.

for those files I am given : 

CommonClient.alx

CommonClient.cod

CommonClient.debug

CommonClient.jad

CommonClient.jar

[the same for the 2 other libraries].

 

When you follow the tutorial metionned in the first post, you build the app using the eclipse plugin, you have to add the jars to the build path then when you test on the simulator you copy the cod files into the simulator folder, and on the device you have to install the .alx files.

 

I'm trying to get this to work using webworks by using phonegap (because I have a html5/javascript interface that I already use on ios).

 

I narrowed down my options to 2 approaches 

1) adding the jars to the phonegap project. 

2) using them as a library application 

 

the problem is before I started this I had 0 blackberry experience so i'm nearly purely guessing.

 

when I try 1) I get 

but when I do this I get 

> Error starting MyApp: Module 'MyApp' has verification error 1691 at
> offset 0ed9 (code file version 79)

I googled it and as you said I should preverify the jar but when I do this I get

 

 

console: 

C:\BBWP\bin>preverify -classpath C:\BBWP\lib\net_rim_api.jar "C:\sybase new jars \src\sup_client_rim.jar" JAR file creation failed with error -1 The preverified classes if any are in tmp22556. See jar log of errors in output\ jarlog.txt

 

jarlog.txt

Error: No such file or directory
jar -cfm "output\sup_client_rim.jar" tmp22556\\META-INF\MANIFEST.MF -C tmp22556 .

 

 

When I tried 2) I get 

 

I just don't know how to set the phonegap/webworks parameters so that it accesses a library application

 

Any ideas ? 

 

Cheers 

 

Jason

Retired
jeffheifetz
Posts: 518
Registered: ‎07-18-2011
My Device: Bold

Re: Calling a third party lib/jar

Hi jason_rogers,

 

This is definately something that can be done, its very similair to what is done for BBM right now.

 

What you have are a set of compile-time jars and a set of cods that need to be on the device for run time. So what you need to do is add the jars to the buildpath but make sure they are not packaged into your app.

 

Firstly, its important to note that by adding the jar you can access the APIs from Java, but not javascript. To access from JavaScript you will need to build a custom WebWorks Extension. Luckily there are plenty of examples (you can look at any of our own APIs) or the community api repo here -https://github.com/blackberry/WebWorks-Community-APIs.

If you want to build an extension for phonegap you will then package your webworks extension in a phonegap plugin. I'm not sure how many examples are out there, but I'm sure we can figure it out.

 

Secondly, to be able to compile your extension and access the 3rd party lib  you need to have a dependency section in your library.xml, something like the following.

extension id="blackberry.sybase.extension">
    <entryClass>blackberry.sybase.SybaseExtension</entryClass>
    <dependencies>
        <jar path="CommonClient.jar" />
    </dependencies>
</extension>

 

Lastly, to test your application you need to load your app on the device and load CommonClient.cod as well.

 

Hope that clarifies a few things




1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
New Contributor
jason_rogers
Posts: 9
Registered: ‎09-19-2011
My Device: curve 9300

Re: Calling a third party lib/jar

Hi Jeff

 

Thanks for your help, 

 

I have currently dropped phonegap and focused on getting it running with just webworks but still no joy

 

I have no idea how to create these dependencies (I've been searching and there is 0 information on the webworks pages about creating dependencies between a plugin and a 3rd party lib.

 

the 2 major questions I can't figure are : 

 

- how do you write a extension that access a third party library ? the only solution I found was to compile a jar sepratly form the project and add that to the project, otherwise we get compilation errors form bbwp. Is this the correct way of doing it ? 

 

- what path do I need to specify in the library.xml ? is it a path in the project? on the hard disk ? on the device ? 

 

I'm attaching a link to our test project 

http://dl.dropbox.com/u/40792956/MyExtension.zip

I do hope you'll no tthink its too daring if you could have a look at what we are doing wrong.

 

CHeers

 

Jason 

 

Retired
ababut
Posts: 46
Registered: ‎07-08-2010
My Device: Superberry

Re: Calling a third party lib/jar

Jason, let me understand the deployment scenario of the 3rd party library better.

Which one of these two is it?
1) A pre-compiled COD file containing the logic and a shell JAR file that you have to put on the classpath for compile time linking purposes?
2) A JAR file containing all the logic of the library that you put on the classpath and compile together with your application?
-------------------------------------------------------------------------------------------------
Useful resources, food for the brain:
Web(Works) KB - http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/tkb-p/browser_dev%40tkb
New Contributor
jason_rogers
Posts: 9
Registered: ‎09-19-2011
My Device: curve 9300

Re: Calling a third party lib/jar

Hi Ababut

 

To get tutorial of these libraries to work I had to: 

 

- in blackberry eclipse plugin add the jar libraries to the project

- - on the simulator add the cod files in the simulator folder

- - on the device install application using the .alx files

 

so I would say 1

the libraries I have are precompiled

 

I am now looking to create a plugin that calls these precompiled libraries.

 

 


List of the files given by Sybase 

 

CommonClient.alx

CommonClient.cod

CommonClient.debug

CommonClient.jad

CommonClient.jar

sup_client_rim-1.debug

sup_client_rim-2.debug

sup_client_rim.alx

sup_client_rim.cod

sup_client_rim.debug

sup_client_rim.jad

sup_client_rim.jar

UltraLiteJ-1.debug

UltraLiteJ-2.debug

UltraLiteJ-3.debug

UltraLiteJ-4.debug

UltraLiteJ-5.debug

UltraLiteJ.alx

UltraLiteJ.cod

UltraLiteJ.debug

UltraLiteJ.jad

UltraLiteJ.jar

Retired
ababut
Posts: 46
Registered: ‎07-08-2010
My Device: Superberry

Re: Calling a third party lib/jar

So it's scenario 1 :smileyhappy:

Ok, you'll have to do the following things to use it:

1) Write a Java extension that uses that library. Follow Jeff's tutorial on how to get set up and developing extension using the eJDE/JDE. It will basically be a library project that has the Sybase library on its classpath. Test it, make sure everything on the Java side works as expected.

2) Copy your extension's package(s) to a subfolder of your choosing inside the "ext" folder of the WebWorks Packager installation.

3) Copy the 3rd party library JAR to the same subfolder you created in step two, at the root of your package structure.

4) Create the library.xml for that extension and make sure you include the dependencies tag that Jeff has mentioned above. It needs to reference the JAR correctly.

5) Deploy the Sybase COD files to your device.

6) Add the <feature> tag of your extension to your WebWorks App's config.xml file.

7) Run bbwp to build your WebWorks app. Deploy to device and it should be able to link to the Sybase library correctly.

What you're doing in steps 3 and 4 is telling bbwp to include the JAR files on the classpath when compiling your app with the extension. This will allow the application to compile successfully. The contents of the JAR are now part of your WebWorks app's COD file and will hopefully allow it to link at runtime with the pre-deployed library CODs.

Let me know if this worked for you.
-------------------------------------------------------------------------------------------------
Useful resources, food for the brain:
Web(Works) KB - http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/tkb-p/browser_dev%40tkb