[英]How to call a plugin method from another plugin in Eclipse?
I'm having the following situation: 我遇到以下情况:
I want to extend the functionality of a given plugin A (I have it's source code and start it by running the project as an Eclipse Application which opens a new Eclipse IDE which provides the plugins functionality) with an plugin BI am writing. 我想扩展给定插件A的功能(我有它的源代码,并通过作为Eclipse应用程序运行该项目来启动它,该应用程序打开了一个新的Eclipse IDE,该IDE提供了插件功能),并且正在编写一个插件BI。
My plugin does run when I run it as a Java Application. 当我将其作为Java应用程序运行时,插件确实可以运行。 Let's assume it just prints Hello World in the console. 假设它只是在控制台中打印Hello World。 What I want is that I can call the function which does that from plugin A. 我想要的是可以调用从插件A执行此操作的函数。
What I did: 我做了什么:
What happens: 怎么了:
When the instance of the class in plugin B should be created, the program crashes with this error: 当应创建插件B中的类的实例时,程序会因以下错误而崩溃:
java.lang.NoClassDefFoundError: de/name_of/plugin_b/package/ClassName
[...]
Caused by: java.lang.ClassNotFoundException: de.name_of.plugin_b.package.ClassName cannot be found by de.name_of.plugin_a.package_1.0.0.qualifier
I guess I'm missing something imporant - can someone help me out on what it is? 我想我缺少了重要的东西-有人可以帮我解决这个问题吗?
Edit 2: 编辑2:
I've just read that I have to add "." 我刚刚读到我必须添加“。” to the classpath. 到类路径。 Seems like this solved the issue! 好像这样解决了问题! Thanks for making me dig deeper into the manifest, greg! 感谢您让我深入探索清单,格雷格!
I do get a different error now tho, which also seems to be connected to me making mistakes when creating the plugin as I do not get this error when I run plugin B as a Java Application. 我现在确实遇到了另一个错误,这似乎也与我有关,在创建插件时会出错,因为当我将插件B作为Java应用程序运行时没有出现此错误。
java.lang.NoSuchMethodError: org.apache.lucene.store.FSDirectory.open(Ljava/nio/file/Path;)Lorg/apache/lucene/store/FSDirectory;
The problem is, tho, that this method does exists (see lucene API here ). 问题是,此方法确实存在(请参阅lucene API )。
As seen in the manifest, I added the lucene-jars to the dependencies of plugin B. 如清单所示,我将lucene-jars添加到插件B的依赖项中。
You need to include every package that other plugins use in the Export-Package
section of your plugin. 您需要在插件的“ Export-Package
部分中包含其他插件使用的每个包。 In the MANIFEST.MF editor this is on the 'Runtime' tab in the 'Exported Packages' section. 在MANIFEST.MF编辑器中,这位于“导出的程序包”部分的“运行时”选项卡上。
You don't need an extension point to make this work. 您不需要扩展点即可完成这项工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.