将我正在开发的插件导出为可部署功能后,我收到“未找到类”异常。
通常我将生成的Jar放在dropins文件夹中就可以使用它了。但是在使用IWorkspaceRunnable
添加了似乎保存对资源的更改的正确方法之后当我尝试运行已部署的插件时,我开始收到 not Class Def 异常。 (请注意,在不部署的情况下进行测试时,该插件运行良好,也称为“作为 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());
}
知道如何让它工作吗?
org.eclipse.core.resources
,其中包含 IWorkspaceRunnable
,已经存在于我的“插件依赖项”文件夹中。我认为它在某个时刻自动到达那里。我应该在其他地方放置/引用那个特定的 jar 吗?我没有对 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 文件夹中并运行。
最佳答案
ClassNotFoundException
表示类路径中缺少某些内容。也许您在类路径中缺少一个库。
As the name suggests classNotFoundException in Java is a subclass of java.lang.Exception and Comes when Java Virtual Machine tries to load a particular class and doesn't found the requested class in classpath.
关于java - 使用 IWorkspaceRunnable 后出现类未找到异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17174106/