我是这么做的…………
环境:windowsXP,eclipse3.2,jdk5.0
步骤:
1.新建一个普通的java project
2.导入工程包
org.eclipse.swt.win32.win32.x86_3.1.2.jar
swt.jar
org.eclipse.jface.text_3.1.2.jar
org.eclipse.jface_3.1.1.jar
org.eclipse.core.runtime_3.1.2.jar
org.eclipse.ui.workbench_3.1.2.jar
org.eclipse.core.commands_3.1.2.jar
org.eclipse.equinox.common_3.1.2.jar
3 把
swt-awt-win32-3139.dll
swt-gdip-win32-3139.dll
swt-win32-3139.dll
swt-wgl-win32-3232.dll
放到了 \Java\jdk1.5.0_02\bin 下面
程序代码,编译没问题,没有错误也没有警告
package swt01;
import org.eclipse.swt.widgets.*;
public class Swt001 {
public static void main(String args []){
Display display = Display.getDefault();
Shell shell = new Shell();
shell.setSize(500,500);
shell.setText( "Hello ");
shell.open();
while (!shell.isDisposed()){
if (!display.readAndDispatch())
display.sleep();
}
}
}
运行之后,控制台里出现
Exception in thread "main " java.lang.UnsatisfiedLinkError: no swt-win32-3236 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
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 swt01.Swt001.main(Swt001.java:7)
帮帮我吧,2天都没搞定,郁闷死了 TAT
------解决方案--------------------
你要把swt-win32-3236.dll的文件引入到classpath中来才可以运行。
------解决方案--------------------
把swt-win32-3236.dll导入就可以了
导入的时候把那个钩选上就OK