java - 为什么我的 Eclipse 插件在一个工作区中启动正常,但在另一个工作区中却不行?

标签 java eclipse eclipse-plugin

我已经为 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/

相关文章:

java - tomcat v8.0 无法在 ubuntu 上启动

java - 在 Eclipse 插件中显示复杂对话框的正确方法是什么?

php - Eclipse Europa 的 Smarty 插件

c# - 桌面应用程序的推送通知?

java - 如何使用 Jersey 2.x 发送 JSON 请求

java - 如何限制 Eclipse 中的搜索匹配以过滤掉评论中的结果?

java - 运行 JUnit 测试忽略模块路径

java - 在 OpenGL (lwjgl) 中查看网格

java - 如何根据限定符选择要绑定(bind)的特定子类型

eclipse - 我刚刚在 Eclipse 上安装了 EGit——但是它在哪里?