问题描述
我有一个 Eclipse 插件项目,它依赖于我的 Eclipse 工作区中的其他项目.在Java Build Path"->Projects"选项卡下添加项目依赖项,并在Order and Export"中选择项目后,我得到一个 java.lang.NoClassDefFoundError.
I have an Eclipse plugin project, and it depends on other projects that I have in my Eclipse workspace. After adding the project dependencies under "Java Build Path" -> "Projects" tab, and also selecting the project in the "Order and Export" I get a java.lang.NoClassDefFoundError.
我假设其他项目尚未正确包含在插件中.有谁知道如何解决这个问题?
I'm assuming that the other projects have not been properly included into the plugin. Does anyone know how to fix this?
谢谢,詹姆斯
推荐答案
Eclipse 插件项目管理依赖项的方式与常规 Java 项目不同.
An Eclipse plug in project manages dependencies differently than a regular Java project.
我假设您正在添加带有 .class 文件的包.
I'm assuming that you're adding packages with .class files.
在您的 Eclipse 插件项目中定义一个库文件夹.将任何外部类和/或 jar 复制到库文件夹.
Define a library folder in your Eclipse plug-in project. Copy any external classes and / or jars to the library folder.
打开 META-INF 目录下的 MANIFEST.MF 文件.您会看到一个底部有 8 个选项卡的格式化编辑器.
Open up the MANIFEST.MF file under the META-INF directory. You'll see a formatted editor with 8 tabs on the bottom.
单击运行时选项卡.将 library 文件夹中的外部类和/或 jar 添加到 Classpath.这也会将这些外部类和/或 jar 添加到项目的 Java 构建路径中.
Click on the Runtime tab. Add the external classes and / or jars in the library folder to the Classpath. This will also add these external classes and or jars to the Java Build Path of the project.
单击 Dependencies 选项卡,然后在 Imported Packages 对话框中添加其他 Java 项目.您必须选中标有显示未导出的包"的框.如果您的其他 Java 项目是 Eclipse 插件,请将它们添加到所需插件下.
Click on the Dependencies tab, and add the other Java projects in the Imported Packages dialog. You have to check the box labeled "Show non-exported packages". If your other Java projects are Eclipse plug ins, add them under Required Plug-ins instead.
这篇关于具有其他项目依赖项的 Eclipse 插件项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!