at java.lang.System.loadLibrary(System.java:993)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:123)
at org.eclipse.swt.internal.win32.OS. <clinit> (OS.java:18)
at org.eclipse.swt.widgets.Display. <clinit> (Display.java:125)
at org.FirstLab.main(FirstLab.java:16)
以上错误是在下段代码采用[JAVA应用程序]方式运行时产生的,但以[SWT应用程序]方式运行时ok的,为什么?
package org;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
public class FirstLab {
public static void main(String arg[]){
Display display=new Display();
Shell shell=new Shell();
shell.setLayout(new GridLayout(1,false));
Label label1=new Label(shell,SWT.BORDER);
label1.setText( "First Label ");
Label lbl2=new Label(shell,SWT.HORIZONTAL|SWT.SEPARATOR);
lbl2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
shell.setLayout(new GridLayout(2,false));
new Button(shell,SWT.CHECK).setText( "check ");
new Button(shell,SWT.RADIO).setText( "radio:01 ");
new Button(shell,SWT.PUSH).setText( "push ");
new Button(shell,SWT.TOGGLE).setText( "toggle ");
new Button(shell,SWT.FLAT).setText( "flat ");
//final Button btn=new Buuton(shell,SWT.PUSH);
//btn.addSelectionListener(new SelectionAdapter());{
System.out.println( "p ");
//}
shell.open();
while (!shell.isDisposed()){
if (!display.readAndDispatch()){
display.sleep();
}
}
display.dispose();
}
}
------解决方案--------------------
看来你需要去找一个SWT依赖的dll文件(在eclipse的文件下搜)和你的程序放在一起.