我正在尝试运行一个非常简单的JFace程序:
import org.eclipse.jface.window.*;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
public class HelloSWT_JFace extends ApplicationWindow{
public HelloSWT_JFace(){
super(null);
}
protected Control createContents(Composite parent){
Text helloText = new Text(parent, SWT.CENTER);
helloText.setText("Hello SWT and JFace");
parent.pack();
return parent;
}
public static void main(String[] args) {
HelloSWT_JFace awin = new HelloSWT_JFace();
awin.setBlockOnOpen(true);
awin.open();
Display.getCurrent().dispose();
}
}
据我所知,所有库都已安装,Eclipse中的代码没有给我任何错误。尽管如此,当我跑步时我得到了
和长错误报告:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IProgressMonitor
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IProgressMonitor
at java.net.URLClassLoader$1.run(Unknown Source)
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)
... 6 more
有谁知道造成这种情况的原因是什么?
请注意;我查看了THIS问题并按照解决方案进行了操作,但安装Equinox插件无法正常工作。
答案 0 :(得分:1)
感谢Baz提供的链接,我找到了解决方案,确保添加了所有必需的Jars(我错过了一对)。
必要的罐子是:
org.eclipse.core.commands_<version info>.jar
org.eclipse.equinox.common_<version info>.jar
org.eclipse.jface_<version info>.jar
org.eclipse.osgi_<version info>.jar
org.eclipse.ui.workbench_<version info>.jar
更多信息可以在Baz提供的链接中找到: "Identify the Required External JAR Files for SWT and JFace"