Wednesday, September 30, 2009

You might need to preverify the jar file. This is how you can preverify a jar file

Go to your JDE installation folder, for Windows XP it is usually C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\bin. If you are using eclipse then you can also find the installation directory of BlackBerry plugin.
2. Copy your jar  file to bin folder.
3. Notice the preverify.exe file. This is the tool we'll use.
4. Now open your command prompt and change your current directory to your JDE installation directory.
5. execute the following command:
preverify -classpath "JDE_PATH_HERE\lib\net_rim_api.jar" "your_jar_filename"
6. Notice that in bin directory, another folder named output has been created. Preverified jar file resides here. Copy the preverified jar file with the same name that the non-preverified jar file has.
7. Now replace the non-preverified jar file with the verified one. Use this jar in next steps

Create a new Blackberry project with any name like LibProject.
   Right-click on the project and go to Properties.
   Go to Blackberry Project Properties. Click on the Application tab.
   Under Project Type, change to Library.
   Next, go to the Java Build Path.
  go to libraries and add the jar file as an external library.
  Go to Order and Export tab here, and mark your jar file as exportable
  Click OK.

Build the library project.

Now, create your main BlackBerry project
   Keep this projects type to as you wish it to be.
   Now go to the properties of this project, In the Java Build Path, add the LibProject project as a Project dependency.

You are pretty much ready to import the jar in your code. Try to import a class and see if it works.

Alternatively, what I think that we might skip the first works of creating a new project and try to add the jar directly to our app. I think that might also work. Though I did not try it yet. Let me know if anyone was successful doing it.

That’s all for now

7 Comments:

  1. Unknown said...
    Note that in order for preverify to work you must have the JDK in your path, otherwise it will exit with an error message telling you to see jarlog.txt which will have:
    Error: No such file or directory
    jar -cfm "output\ksoap2-j2me-core-2.1.2.jar" tmp22201\\META-INF\MANIFEST.MF -C tmp22201 .

    That was easy enough to fix but now I have preverify working fine, not reporting any errors and generating the jar in the output directory. But then when I go to run in eclipse I get:
    Description Resource Path Location Type
    Error!: Error: preverifier failed: ... BlackBerry Java Problem

    Any ideas?

    The only thing I can think of is that I have the JDK SE in my path not the JDK micro edition...

    Will post back here when I get this straightened out.
    Unknown said...
    So I figured it out without doing anything at all.
    Step 1: Close eclipse
    Step 2: Open eclipse

    Now it works. Go figure.
    Unknown said...
    Thanks guys this solved a ton of my headaches.
    Unknown said...
    Hii I am also getting

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

    can anyone please explain what do I have to do to solve it. How can i involve those JDK in path.
    Arvind Awasthi said...
    pete can you help me about how you solve the "Error!: Error: preverifier failed" error
    Unknown said...
    can u give me tutoial to the prverify for BBM jar

    net_rim_bb_qm_platform.jar


    i prverify it and get the tmp29350 folder

    first when i use this command
    jar -cvfm net_rim_bb_qm_platform.jar .\net\rim\blackberry\api\bbm\platform\*.class;
    i get this error

    C:\Program Files\Research In Motion\BlackBerry JDE 5.0.0\bin>jar -cvfm net_rim_b
    b_qm_platform.jar .\net\rim\blackberry\api\bbm\platform\*.class;
    'jar' is not recognized as an internal or external command,
    operable program or batch file.



    so i use this command

    "C:\Program Files\Java\jdk1.6.0_33\bin\jar.exe" -cf "output2\net_rim_bb_qm_platform.jar" tmp29350/net/

    successfully get the new jar

    but when i used it some classes
    Arindam................. said...
    Error preverifying class mypackage.API$1
    java/lang/NoClassDefFoundError: com/arcot/base/test/Test

Post a Comment