2

I got this error when I included guava-11.0-rc1.jar which contains the package com.google.common.* . But when I try to package it, it gives me the error:

Error preverifying class com.google.common.collect.Ordering MyApp line 0
BlackBerry Packaging Problem

Can anybody tell me what can be done to solve this? Thanks in advance.

Nate
  • 31,017
  • 13
  • 83
  • 207
nikita sharma
  • 169
  • 1
  • 8

1 Answers1

3

Make sure the classes in that library are Java-ME compatible. Remember CLDC is a subset of Java SE and the equivalent desktop compilation level would be 1.2

If they were compatible, then to solve the preverification error you must first preverify your jar. You might be wondering what preverification is. There's a good explanation in this answer.

Preverification is usually done (or should be done) by the Eclipse plugin, but some versions do not. If this is your case, you should do it manually. In your JDE folder, there is a tool called preverify. You could find it in a path that typically looks like this in a Windows machine:

(1) C:\Program files\Research In Motion\BlackBerry JDE <vers>\bin\

You'll also need a library called net_rim_api.jar located in a path like this:

(2) C:\Program files\Research In Motion\BlackBerry JDE <vers>\lib\net_rim_api.jar`

This is all you need to launch the command. Open command line and change dir to the bin folder (1). Then type :

    preverify -classpath <classpath for lib> -d <output directory> <file to preverify>

Where:

  • <classpath for lib> is the path in (2)
  • <output directory> is the directory where the preverified jar will be saved.
  • <file to preverify> is the absolute path to the file you want to preverify (guava-11.0-rc1.jar in your case)

If everything went well, now you'll have a new jar in <output directory> which is slightly bigger than the input jar file. This is the one you should include in your project. The preverify tool does not change your original jar.

Community
  • 1
  • 1
Mister Smith
  • 27,417
  • 21
  • 110
  • 193
  • Thank you for the explaination Smith. My Eclipse plugin does the preverification. Should I preverify the jar file separately? – nikita sharma Jan 22 '13 at 09:59
  • Its giving me the following error: Error preverifying class com.google.common.collect.Ordering java/lang/NoClassDefFoundError: java/util/Comparator What should I do now? – nikita sharma Jan 22 '13 at 10:32
  • I added another .jar file from here: https://code.google.com/p/guava-libraries/ But I'm not able to import com.google.common.* package in my blackberry project's java code. Please help me find a solution for this. – nikita sharma Jan 22 '13 at 10:52
  • 1
    That library is not compatible with JavaME as is. `java.util.Comparator` is a JavaSE class, and it does not exist in CLDC. That's where the problem is. – Mister Smith Jan 22 '13 at 11:04
  • Yes, I understand that but now I have downloaded another guava-gwt-14.0-rc1.jar file available on the link above. The project packages correctly, and I'm able to sign my blackberry application, but I'm unable to import com.google.common.* package in my code. – nikita sharma Jan 22 '13 at 11:25
  • That is the version for Google GWT users (Google Web Toolkit). GWT is a development toolkit made by Google, and it contains several libraries your newly downloaded version depends on. Again, Guava is not JavaME compatible, because it uses Java SE 1.6 stuff, and in BlackBerry you only have CLDC classes. – Mister Smith Jan 22 '13 at 13:00
  • So with that, I cannot link my GWT with my Blackberry Project. Thanks Smith. So, I can't use the Guava API then. – nikita sharma Jan 23 '13 at 05:38