我新建了一个windows application,运行时总是报错说:'java.lang.NoClassDefFoundError',还弹出一个窗口说:'could not find the main class ,program will exit'
以下是源代码
package com.swtdesigner;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class HelloWorld {
private static Text text;
/**
* Launch the application
* @param args
*/
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(500, 375);
shell.setText( "SWT Application ");
//
shell.open();
text = new Text(shell, SWT.BORDER);
text.setBounds(152, 135, 80, 25);
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
------解决方法--------------------------------------------------------
经测试,正常显示。
去掉包结构看看,这个com.swtdesigner好像和swtdesigner同包名