Blackberry: Verificattion error when using Library project as External Jar

痞子三分冷 提交于 2019-11-28 12:08:15

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/9902639/blackberry-verificattion-error-when-using-library-project-as-external-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!