1

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?

dev_android
  • 7,874
  • 21
  • 84
  • 143

2 Answers2

5

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.

Richard Le Mesurier
  • 27,993
  • 19
  • 127
  • 242
  • 1
    How to preverify the Jar file when I am using Eclipse with Blackberry plug in? – dev_android Mar 28 '12 at 09:45
  • preverify.exe is located in the folder where you have installed Eclipse Plugin. Run a search for this file into all nested folders. And check this instruction: http://getablogger.blogspot.com/2009/09/how-to-include-external-jar-file-in.html –  Mar 28 '12 at 10:36
3

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.

Mister Smith
  • 24,695
  • 17
  • 97
  • 181