进行插件开发学习时,将Eclipse Articles下的一些插件开发例子直接导入到Eclipse3.4.1环境下无法直接运行,以Eclipse Article:Simplifying Preference Pages with Field Editors(http://www.eclipse.org/articles/Article-Field-Editors/field_editors.html)为例,说明如下
在Eclipse3.4.1环境下新建插件开发工程,拷贝例子程序到src目录下,并修改MAINFEST.MF文件中的Bundle-Activator属性值,运行插件报如下错误:
org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter$TerminatingClassNotFoundException:
An error occurred while automatically activating bundle xxx(line no.).
解决方法
1.修改构造函数
public HTMLEditorPlugin(IPluginDescriptor descriptor) { | ||||
super(descriptor); | ||||
plugin = this; | ||||
} |
修改为
public HTMLEditorPlugin() { | ||
} | ||
2.添加start(BundleContext context)和stop(BundleContext context)方法
private BundleContext context = null; | |||||||
/* | |||||||
* (non-Javadoc) | |||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) | |||||||
*/ | |||||||
public void start(BundleContext context) throws Exception { | |||||||
super.start(context); | |||||||
plugin = this; | |||||||
} | |||||||
/* | |||||||
* (non-Javadoc) | |||||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) | |||||||
*/ | |||||||
public void stop(BundleContext context) throws Exception { | |||||||
plugin = null; | |||||||
super.stop(context); | |||||||
} |