我想運行一個非常簡單的JFace程序:無法編譯簡單的JFACE程序; java.lang.NoClassDefFoundError
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插件不起作用。
你加'org.eclipse.core.runtime <版本> .jar'到你的項目? – Baz 2013-05-15 17:42:17
[This](http://wiki.eclipse.org/JFace#Identify_the_Required_External_JAR_Files_for_SWT_and_JFace)也可能有幫助。 – Baz 2013-05-15 18:12:26
@Baz是的,我做過 – CodyBugstein 2013-05-17 15:04:11