导入库项目时出现 NoClassDefFoundError
我目前正在使用版本 4.6.1 (Windows Vista + Eclipse) 编写一个单元测试项目。我的项目分为 3 部分:
- A. 单元测试应用程序(类型:CLDC 应用程序)
- B. 要测试的应用程序(类型:CLDC 应用程序)
- C. 库项目(类型:库,未导入 .jar 文件)
A 项目应该引用 B 中的代码(当然甚至是 C 中的代码)。我想指定我可以毫无问题地运行项目 B(引用 C)。当我尝试运行项目 A 时,我的问题开始了。
我执行了以下操作:
将 B 项目类型从 CLDC 应用程序更改为库 B 引用项目 C A 引用项目 B 将所有项目设置为“Active for Blackberry” 基本上,A 将另外两个项目视为两个嵌套库。 代码构建成功,但问题是执行过程中B调用C库的类时,抛出如下异常:
NoClassDefFoundError
没有详细消息
任何帮助将不胜感激。
非常感谢
I'm currently writing a unit test project using the version 4.6.1 (Windows Vista + Eclipse). My project is divided in 3 part:
- A. Unit test application (type:CLDC application)
- B. Application to be tested (type:CLDC application)
- C. A library project (type: library,no .jar file imported)
The A project should reference the code present in B (and of course even in C). I would like to specify that I can run without problems the project B (referencing C). My problems start when I try to run the project A.
I performed the following operations:
changing the B project type from CLDC application to library
B references the project C
A references the project B
set all project as "Active for Blackberry"
Basically A sees the two other project as two nested libraries.
The code is built successfully,but the problem is that when a class of the C library is called by B during the execution, the following exception is thrown:
NoClassDefFoundError
No detail message
Any help would be really appreciated.
Many Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NoClassDefFoundError 意味着 A 在运行时找不到 C。通常的原因是C未能部署到目标设备(模拟器或真实设备)上。
解决方案 1:
对于项目 A,在“项目”->“属性”->“Java 构建路径”下,确保 C(您的库项目)列在“项目”下,并在“订购和导出”上选中相应的复选框选项卡。这应该确保在构建和部署过程中导出库。
解决方案2:
在项目A中添加一个到库C源的符号链接(右键单击项目->构建路径->链接源)。这将强制在构建项目 A 时包含库的源代码。
A NoClassDefFoundError means that A cannot find C at runtime. The usual cause is that C failed to be deployed onto the target device (simulator or real device).
Solution 1:
For project A under Project->Properties->Java Build Path ensure C (your library project) is listed under 'Projects' and the corresponding checkbox checked on the 'Order and export' tab. This should ensure that the library is exported during the build and deployment process.
Solution 2:
In project A add a symbolic link (right click project->Build Path->Link Source) to the library C source. This will force the library's source code to be included when project A is built.