我已经为 Eclipse 创建了一个插件并将其导出为 JAR 文件。我把它放在我的 Eclipse RCP 发行版的插件目录中。然后我打开 Eclipse,插件按预期运行。我转到我的另一台计算机并将 JAR 放在 Eclipse RCP 分发的插件目录中,然后打开 Eclipse。
我在错误日志中收到如下消息:
- 启动插件时遇到的问题:“org.osgi.framework.BundleException: bundle MyPlugin 的 myplugin.Activator.start() 中出现异常”
- 无法执行扩展的早期启动代码
- 错误的扩展规范
- 启动类必须实现 org.eclipse.ui.IStartup
虽然其中一些消息让我感到困惑,因为这是我的 Activator 类的样子:
public class Activator extends AbstractUIPlugin implements IStartup {...
例如,它清楚地实现了 IStartup。
有没有人知道这里发生了什么,或者至少我应该朝哪个方向解决这个问题?
编辑
我现在创建了一个名为 StartupClass.java 的新类:
package myplugin;
import org.eclipse.ui.IStartup;
public class StartupClass implements IStartup {
@Override
public void earlyStartup()
{
}
}
然后我将我的 plugin.xml 更改为如下所示:
<extension point="org.eclipse.ui.startup">
<startup class="myplugin.StartupClass" />
</extension>
这会导致类似的错误,例如:
- 自动激活 bundle MyPlugin 时发生错误
- 插件 MyPlugin 无法加载类 myplugin.StartupClass
- 无法执行扩展的早期启动代码
最佳答案
你有org.eclipse.runtime.compatibilty
吗?插件在一个工作区而不是另一个工作区?
您这样做的方式已被弃用,您应该有一个单独的“启动”类并将其指定为 class
你的 <startup>
的属性元素。
来自Eclipse docs on the startup extension point :
Do not specify the plug-in class as the value of the class attribute, or it will be instantiated twice (once by regular plug-in activation, and once by this mechanism). If the extension does not provide a class as an attribute on the startup element, the plug-in's activator (plug-in class) must implement org.eclipse.ui.IStartup.
Note that this form is deprecated and should no longer be used. Its functioning relies on the availability of the org.eclipse.core.runtime.compatibility plug-in and the org.eclipse.core.runtime.compatibility.registry fragment.
关于java - 为什么我的 Eclipse 插件在一个工作区中启动正常,但在另一个工作区中却不行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5207325/