日食中的 SWT Java JDE 不工作

SWT in eclipse Java JDE not working

当我将下面的Java代码输入到eclipse中时,它returns出错了。 eclipse 教程告诉我这应该可行。我究竟做错了什么? This is a picture of my code。

import org.eclipse.swt;
public class SWTHELLOWORLD{
      public static void main(String[] args){
           Display display=new Display();
           Shell shell = new Shell(display);
           shell.setText("Hello world");
           shell.open();
           while(!shell.isDisposed()){
                if(!display.readAndDispatch())display.sleep();
           }
           display.dispose();
     }
}

当我 运行 作为 java 应用程序时,它 returns 这个错误:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    Display cannot be resolved to a type
    Display cannot be resolved to a type
    Shell cannot be resolved to a type
    Shell cannot be resolved to a type

您使用了

public static void main (Strings[] args)

而正确的表达方式是

public static void main (String [] args)

注意它是最后没有 's' 的字符串。

您没有导入显示和 Shell classes.

您应该将以下导入添加到 class 的顶部:

import org.eclipse.swt.widgets.Display
import org.eclipse.swt.widgets.Shell

仅导入 org.eclipse.swt 不会导入您需要的所有 class。