简体   繁体   English

Eclipse插件无法从类文件夹中找到类

[英]Eclipse plugin cannot find class from class folder

I'm developing an Eclipse plugin, and want to use some pre-compiled classes which I've put to lib/ folder in my project (so the directory structure looks like {proj_root}/lib/com/example/Required.class ). 我正在开发一个Eclipse插件,并希望使用一些预先编译的类,我已经将这些类放到我的项目中的lib/文件夹中(所以目录结构看起来像{proj_root}/lib/com/example/Required.class ) 。 Then I've added lib/ folder as class folder to project's build path. 然后我将lib/文件夹作为类文件夹添加到项目的构建路径中。 At build time all is working fine, I can import and use that classes in my code. 在构建时,一切正常,我可以在我的代码中导入和使用这些类。 And now the problem is, when I'm running my plugin in separate Eclipse instance I get ClassNotFoundException by my plugin refering to class from precompiled classes folder. 现在的问题是,当我在单独的Eclipse实例中运行我的插件时,我的插件引用了ClassNotFoundException ,引用了precompiled classes文件夹中的类。

I tried specifying my class folder in "Order and export" tab in Build path settings. 我尝试在构建路径设置的“订购和导出”选项卡中指定我的类文件夹。 Also I tried setting checkbox in plugin's build.properties GUI editor in front of lib/ folder to be included in binary build. 此外,我尝试在lib/文件夹前面的插件的build.properties GUI编辑器中设置复选框,以包含在二进制构建中。 In that case if I export my plugin to JAR I can see lib/ folder inside it, with my classfiles, but at runtime my plugin still cannot find any of classes from lib/ . 在这种情况下,如果我将我的插件导出到JAR,我可以使用我的类文件在其中看到lib/文件夹,但在运行时我的插件仍然无法从lib/找到任何类。

Can you please give me an advice on how I should tell Eclipse where to find that classes at runtime? 你能否告诉我如何告诉Eclipse在运行时哪里可以找到这些类?
PS.: PS:

  1. I did research on stackoverflow on this problem, but all suggestions are the same: just add class folder in project's Build path. 我就此问题研究了stackoverflow,但所有建议都是一样的:只需在项目的Build路径中添加class文件夹即可。
  2. At this point in plugin's build.properties Text editor, eclipse shows warning The class folder 'lib/' is not associated to any output library entry. 此时在插件的build.properties文本编辑器中,eclipse显示警告The class folder 'lib/' is not associated to any output library entry. and suggests to make this modification of code: output.. = bin/,lib/ . 并建议对代码进行修改: output.. = bin/,lib/ I have tried that solution but it is seems to change nothing with the problem. 我尝试过这个解决方案,但似乎没有改变这个问题。

It sounds very much like you have added the lib folder to the "Java Build Path" properties page of the plug-in project. 这听起来非常像您已将lib文件夹添加到插件项目的“Java Build Path”属性页面。

But... for plug-in projects, this does not work as these are OSGi bundles - you must include the lib folder in the PDE Editor on the "Runtime" page: 但是......对于插件项目,这不起作用,因为这些是OSGi包 - 您必须在“运行时”页面的PDE编辑器中包含lib文件夹:

OSGi的类路径描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM