在开发swt应用中,使用了TableViewer类,导入了org.eclipse.jface_3.7.0.v20110928-1505.jar类库了,eclipse也不报错了,但是运行是就是报以下错误。

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/ISafeRunnable
at gui.Table.(ZZZTable.java:23)
at gui.Table.main(ZZZTable.java:91)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.ISafeRunnable

根据给出的提示说org/eclipse/core/runtime/ISafeRunnable未找到,于是就引入了org.eclipse.core.runtime_3.7.0.v20110110.jar包,运行时还是报这个错误。

后来得知,这个错误是由于给类的定义是在org.eclipse.equinox.common_3.6.0.jar,这样运行是不报错了。在http://www.eclipsezone.com/eclipse/forums/m92035942.html说到

The ISafeRunnable interface is located in the equinox plugin (org.eclipse.equinox.common). If you add the SWT library to your project, it should be added to the build path automatically. You can do this by right-clicking your project, choosing Build Path/Add Libraries… and then selecting the SWT Library. Afterwards, your project should contain a new folder, having the same icon as the JRE folder, and containing a couple of jars, including org.eclipse.swt… and org.eclipse.equinox.common.

查看了下ISaftRunnable该类的定义说明

Safe runnables represent blocks of code and associated exception handlers. They are typically used when a plug-in needs to call some untrusted code (e.g., code contributed by another plug-in via an extension). This interface can be used without OSGi running. Clients may implement this interface.

不过我在导入这个类库是在eclipse rpc版中导入的,不知道其他的eclipse有没有这个类库。

声明:未经允许禁止转载 东东东 陈煜东的博客 文章,谢谢。如经授权,转载请注明: 转载自东东东 陈煜东的博客

本文链接地址: ISafeRunnable 类定义未找到 – https://www.chenyudong.com/archives/isaferunnable-class-definition-not-found.html