dev_android
dev_android

Reputation: 8828

Blackberry: Verificattion error when using Library project as External Jar

I have created two Blackberry project in Blackberry Java Plug-in for Eclipse, i.e. MyProjectApp(set as application project) and MyProjectLib(set as Library project). Now I have created a simple MainScreen class like below:

public class SampleScreen  extends MainScreen {

    public SampleScreen (){
        RichTextField topbar = new RichTextField("hello world");
        add(topbar);
    }

}

Now I export MyProjectLib as Jar file and add the same in MyProjectApp as external Jar. Now I want to fire the SampleScreen using this:

public class MyProjectMain extends UiApplication{

     public static void main(String[] args) {

         MyProjectMain theApp = new MyProjectMain();       
        theApp.enterEventDispatcher();
    }

    public LangHostMain(){        
        // Push a screen onto the UI stack for rendering.
         pushScreen(new SampleScreen());
    }

}

It is giving following error:

Module 'MyProjectApp' has verification errors. Error starting MyProjectApp: Module 'MyProjectApp' has verification errors.

But if I moved the SampleScreen class to MyProjectApp, it is working fine. What is problem in exporting the Jar and use it? What type of Verification is needed?

Upvotes: 1

Views: 746

Answers (2)

user784540
user784540

Reputation:

There's a tool preverify.exe; it makes sure that bytecode is compatible with the BlackBerry platform.

BlackBerry rapc compiler uses java 1.3 bytecode format when it compiles the application to a cod file.

If you have created your jar file in different bytecode format, for instance via compiling with javac version 7.0, then this jar file won't pass the verification.

Try to compile your jar file with key to make it compatible with VM 1.3 bytecode,

Use -target 1.3 key-value combination for the java compiler to build your jar file.

Upvotes: 5

Mister Smith
Mister Smith

Reputation: 28199

In short, using jars in BlackBerry is a mess.

Your jar should be preverified. I've had so many problems in the past trying to do this with eclipse plugin that I usually do it using command line. Inside your JDE path, usually at:

C:\Program files\Research In Motion\BlackBerry JDE x.x.x\bin

There's a program called preverify. Once you preverify your jar, another preverified jar is created at the specified output directory. That is the file you should import in build path.

Upvotes: 3

Related Questions