获取类未找到在eclipse中运行时异常
我在eclipse中运行以下代码,但找到一个类没有找到异常:
I am running the following code in eclipse but getting a class not found exception:
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class DialogClass {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("TEst");
Shell frame = new Shell(SWT.SHELL_TRIM);
PublishGenericArtefactDialog publishGenericArtefactDialog =
new PublishGenericArtefactDialog(frame);
publishGenericArtefactDialog.setTitle("Test");
if (publishGenericArtefactDialog.open() == Window.CANCEL){
try {
throw new Exception("Cancelled");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
和我得到的错误是
TEst
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IStatus
at DialogClass.main(DialogClass.java:19)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IStatus
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 more
需要帮助
如这个线程
您是否在
Manfest.MF
中列出了org.eclipse.core.runtime
作为插件依赖关系?
我认为IStatus
实际上是在Equinox包中,但是运行时运行时包括等分插件。
如果你是只是作为Java应用程序运行它(例如通过在类路径上粘贴Jars),那么你可能需要org.eclipse.equinox.core / runtime
或类似的。
Have you listed the
org.eclipse.core.runtime
as a plugin dependency in theManfest.MF
?
I think that theIStatus
is actually in an Equinox package, but the runtime includes the equinox plugin at runtime.
If you're just running it as a Java application (e.g. by sticking Jars on the classpath) then you'll probably need theorg.eclipse.equinox.core/runtime
or similar.
感谢您的建议。通过添加 org.eclipse.equinox.common
和 org.eclipse.core.commands
到项目的Java Build Path属性 - 我作为SWT应用程序运行。
Thanks for your suggestion. The problem was solved by adding org.eclipse.equinox.common
and org.eclipse.core.commands
to the Java Build Path property for the project - which I run as an SWT application.
正如 AlBlue 在评论中, JFace上的Eclipse wiki确认:
As mentioned by AlBlue in the comment, the Eclipse wiki on JFace confirms:
JFace可以在独立的SWT + JFace应用程序中使用,而不需要Eclipse运行时或Eclipse平台的其他部分。
这在3.2(2006)中变得更容易,JFace的唯一先决条件被减少到:
JFace can be used in standalone SWT+JFace apps, without requiring the Eclipse Runtime or other parts of the Eclipse Platform.
This was made easier to do in 3.2 (2006), with the only prerequisites for JFace being reduced to:
- SWT ,
- 新的
org.eclipse.equinox.common
插件, - 和
org.eclipse.core.commasters
插件。
- SWT,
- the new
org.eclipse.equinox.common
plug-in, - and
org.eclipse.core.commands
plug-in.
有关详细信息,请参阅 Bug 49497 。
For more details, see Bug 49497.
在3.3中,对 org.osgi.framework
包是在 org.eclipse.osgi
中定义的。
如果此插件不存在JFace将继续发挥作用,但没有为其图像提供国际化支持的好处。
In 3.3 an optional dependency on the org.osgi.framework
package was added which is defined in the org.eclipse.osgi
.
If this plug-in is absent JFace will continue to function but without the benefit of internationalization support for its images.