【问题标题】:Class Not Found Exception after using IWorkspaceRunnable使用 IWorkspaceRunnable 后未找到类异常
【发布时间】:2013-06-25 22:06:10
【问题描述】:

在将我正在开发的插件导出为可部署功能后,我得到了 Class Not Found 异常。

通常我将生成的 Jar 放在 dropins 文件夹中,我可以使用它。但是在使用IWorkspaceRunnable 添加了似乎正确的方法来保存对资源的更改之后,当我尝试运行已部署的插件时,我开始收到非类定义异常。 (注意插件在没有部署的情况下运行良好,也就是作为 Eclipse 应用程序运行)

    IWorkspaceRunnable saveTask = new IWorkspaceRunnable() {

        @Override
        public void run(IProgressMonitor monitor) throws CoreException {
            if (fileName != null) try {
                myEditor.save(new File(fileName));
                firePropertyChange(PROP_DIRTY);
                ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
            } catch (Exception e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(null, "Error while saving: \n"+e.toString());
            }
        }
    };
    try {
        ResourcesPlugin.getWorkspace().run(saveTask, null);
    } catch (CoreException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "Error while saving: \n"+e.toString());
    }

知道如何让它工作吗?

包含IWorkspaceRunnableorg.eclipse.core.resources 已经存在于我的“插件依赖项”文件夹中。我认为它在某个时候自动到达那里。还有其他地方我应该放置/引用那个特定的罐子吗?对于我在 org.eclipse.* 中使用的其他类,我没有做任何其他事情。

编辑:这是 MANIFEST.MF

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MyPlugin
Bundle-SymbolicName: MyPlugin;singleton:=true
Bundle-Version: 1.0.0.1
Require-Bundle: org.eclipse.ui,org.eclipse.core.runtime,org.eclipse.ui
 ,org.eclipse.core.runtime,org.eclipse.jface.text,org.eclipse.ui.edito
 rs,org.eclipse.ui.ide,org.eclipse.core.resources;visibility:=reexport
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Vendor: myVendor
Bundle-ClassPath: /usr/share/eclipse/plugins/,.

我如何部署插件:

我将 .jar 放在 /home//.eclipse/org.eclipse.platform_/dropins/ 中,版本为 4.2.0_1543616141。这可能不是部署它的正确方法,但在添加对 org.eclipse.core.resources 的引用之前它就起作用了。

我有兴趣创建一个可以放入 dropins 文件夹并运行的独立式插件。

【问题讨论】:

  • 你能用你的插件 MANIFEST.MF 的样子更新问题吗?
  • @PaulWebster 我添加了 MANIFEST.MF,有什么异常吗?
  • 你的包类路径中不能有 /usr/share/eclipse/plugins,只有 . 或插件中包含的 jars。插件中的任何内容都可以从您的 RCP 应用程序中获得。
  • 是的,我添加了一个拼命尝试让它工作,但我仍然有同样的 CNFE 问题。您在清单中发现任何其他内容吗?
  • 这将是我的第一个插件,所以也许我遗漏了一些明显的东西。

标签: java eclipse eclipse-plugin classnotfoundexception


【解决方案1】:

ClassNotFoundException 表示类路径中缺少某些内容。也许您在类路径中缺少一个库。

顾名思义,Java 中的 classNotFoundException 是 java.lang.Exception 的子类,当 Java 虚拟机尝试加载特定类并且在类路径中找不到请求的类时出现。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-25
    • 2013-04-09
    • 2016-09-13
    • 2016-10-01
    相关资源
    最近更新 更多