简体   繁体   English

无法编译简单的JFACE程序; java.lang.NoClassDefFoundError

[英]Can't compile a simple JFACE program; java.lang.NoClassDefFoundError

I am trying to run a very simple JFace program: 我正在尝试运行一个非常简单的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();

    }

}

As far as I know, all the libraries are installed and the code, in Eclipse, gives me no errors. 据我所知,所有库都已安装,并且代码在Eclipse中没有给我任何错误。 Nonetheless, when I run I get 但是,当我跑步时

JVM错误

and the long error report: 和长错误报告:

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

Does anyone know what could be causing this? 有谁知道是什么原因造成的?

Please note; 请注意; I took a look at THIS question and followed the solutions, but installing Equinox plugins did not work. 我看了这个问题并遵循了解决方案,但是安装Equinox插件无效。

Thanks to the links Baz provided, I found the solution by making sure all the necessary Jars were added (I was missing a couple). 感谢Baz提供的链接,我通过确保添加了所有必需的Jar来找到了解决方案(我错过了几个)。

The necessary jars are: 必要的罐子是:

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 

More info can be found at the link Baz provided: "Identify the Required External JAR Files for SWT and JFace" 可以在提供的链接Baz中找到更多信息: “标识SWT和JFace所需的外部JAR文件”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM