问题描述
在我看来,这就是我想实现是难以置信的简单,但正变得令人难以置信的痛苦。
我有项目A这是一个黑莓应用程序项目。我有项目B这是一个Java库项目。我想从项目A引用项目B。我可以添加一个参考,但是当我运行项目A,这是行不通的。我有源$ C $ C这两个项目无一不是使用Java编译器编译1.4
我曾尝试多种事情,但出于某种原因,这些都失败:
1。 $ P $上项目B P-verify.exe
它失败,错误失败,错误JAR文件创建-1我可以看到,鳕鱼和jar文件已经建立,但是当jar文件添加到项目A并运行它,这是行不通的。不知道如果我需要添加.cod文件。
2。创建新的BlackBerry库项目,并在项目A引用它
我创建一个新项目项目C,然后项目B的jar添加到它。然后,我在项目A的引用添加到项目C。但我不能从项目B导入类
请提出一个出路。
我使用的Eclipse插件,并依托Eclipse的构建能力
想通了回答自己。万一有人在这里发布在此绊倒。具体操作步骤如下:
- 创建您的图书馆和出口为JAR(或下载第三方JAR)
-
在JAR运行preverify.exe
preverify.exe -verbose -classpathC:/ Program Files文件/ Research In Motion公司/黑莓JDE 5.0.0 / lib目录/ net_rim_api.jarjarname.jar
-
如果你是幸运的,你不会遇到任何问题,你会做。但我没有足够幸运。我得到了下面的错误
There are two possible causes of this:
- jar.exe is not added to your PATH. If so, add it (found in your JAVAinstallation directory) to PATH
cvfm or -cfm option on jar.exe fails to execute. I'm not aware of the reason but the way to fix this is to use -cf option, point to the .class files but don't use the manifest file. here is an
example:"C:\Program Files\Java\jdk1.6.0_26\bin\jar.exe" -cf "output\json-1.0.jar" tmp12996/
tmp12996 contains the preverified .class files.You may run into different issues other than the one I've listed above.
Once jar is created from above step, make sure that it's structure is as you anticipate. One way to check is to rename the .jar to .zip, unzip it and then check it. If it is not as you need, you can change the structure and then repack it (I wouldn't do any major changes though)
Then add this newly built jar to your BlackBerry application as a reference i.e. add to Java Build Path in your eclipse and Check it in Order and Export window.
That's it! You are good to go! Run you app!
You may face error indicating that the module contains verification errors when you try to run in the simulator. One possible cause of this issue is that your library (the original JAR) contains APIs that are not compatible with J2ME or BB JRE. You may not get a compiler error when you build your library independently as it is compiled against Java 1.4 (or whatever your version is). Best to figure the issue out is to move all your code into your BB App project and then build it. That will tell you all the issues upfront. You make the changes as required and then move the code back to the library. If you don't have source code for the library you are using (like a 3rd party library), you may be out of luck! Also remember that there could be other issues than what I've hit upon and solved.
I'm documenting this at length as it has taken an awful amount of time for me to figure all this out; and to say the least, was most frustrating!
这篇关于黑莓5.0 - 添加引用一个Java库项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!