RCP加载SWT.DLL的异常

异常如下:

NativeSwing: Exception in thread "main" java.lang.reflect.InvocationTargetException
NativeSwing:  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
NativeSwing:  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
NativeSwing:  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
NativeSwing:  at java.lang.reflect.Method.invoke(Unknown Source)
NativeSwing:  at chrriis.common.NetworkURLClassLoader.main(NetworkURLClassLoader.java:73)
NativeSwing: Caused by: java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
NativeSwing:  no swt-win32-3655 in java.library.path
NativeSwing:  no swt-win32 in java.library.path
NativeSwing:  Can't load library: C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\swtlib-32\swt-win32-3655.dll
NativeSwing:  Can't load library: C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\swtlib-32\swt-win32.dll
NativeSwing:
NativeSwing:  at org.eclipse.swt.internal.Library.loadLibrary(Library.java:267)
NativeSwing:  at org.eclipse.swt.internal.Library.loadLibrary(Library.java:174)
NativeSwing:  at org.eclipse.swt.internal.C.<clinit>(C.java:21)
NativeSwing:  at org.eclipse.swt.widgets.Display.<clinit>(Display.java:138)
NativeSwing:  at java.lang.Class.forName0(Native Method)
NativeSwing:  at java.lang.Class.forName(Unknown Source)
NativeSwing:  at org.eclipse.swt.graphics.Device.<clinit>(Device.java:85)
NativeSwing:  at chrriis.dj.nativeswing.swtimpl.NativeInterface$OutProcess.runNativeSide(NativeInterface.java:796)
NativeSwing:  at chrriis.dj.nativeswing.swtimpl.NativeInterface.main(NativeInterface.java:821)
NativeSwing:  ... 5 more
java.lang.reflect.InvocationTargetException
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
 at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at cn.com.xxx.visualization.editor.DPEditor.newInstance(DPEditor.java:811)
 at cn.com.xxx.visualization.editor.DPEditor$MyDropTargetListener.drop(DPEditor.java:535)
 at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:90)
 at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
 at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
 at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
 at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
 at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
 at org.eclipse.swt.dnd.DropTarget.Drop(DropTarget.java:456)
 at org.eclipse.swt.dnd.DropTarget$3.method6(DropTarget.java:258)
 at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:119)
 at org.eclipse.swt.internal.ole.win32.COM.DoDragDrop(Native Method)
 at org.eclipse.swt.dnd.DragSource.drag(DragSource.java:363)
 at org.eclipse.swt.dnd.DragSource.access$0(DragSource.java:289)
 at org.eclipse.swt.dnd.DragSource$1.handleEvent(DragSource.java:172)
 at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
 at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
 at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
 at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
 at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
 at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
 at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
 at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
 at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
 at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
 at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
 at neu.xxx.Application.start(Application.java:40)
 at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
 at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
 at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
 at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
 at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
 at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
 at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
 at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Caused by: java.lang.RuntimeException: java.net.SocketException: Connection reset
 at chrriis.dj.nativeswing.swtimpl.OutProcessMessagingInterface.openChannel(OutProcessMessagingInterface.java:64)
 at chrriis.dj.nativeswing.swtimpl.MessagingInterface.initialize(MessagingInterface.java:47)
 at chrriis.dj.nativeswing.swtimpl.OutProcessMessagingInterface.<init>(OutProcessMessagingInterface.java:29)
 at chrriis.dj.nativeswing.swtimpl.OutProcessMessagingInterface$SwingOutProcessMessagingInterface.<init>(OutProcessMessagingInterface.java:149)
 at chrriis.dj.nativeswing.swtimpl.NativeInterface$OutProcess.createOutProcessMessagingInterface(NativeInterface.java:682)
 at chrriis.dj.nativeswing.swtimpl.NativeInterface$OutProcess.createOutProcessCommunicationChannel(NativeInterface.java:436)
 at chrriis.dj.nativeswing.swtimpl.NativeInterface.open(NativeInterface.java:187)
 at control.Pendubot.PendubotFlashPanel.initialize(PendubotFlashPanel.java:30)
 at control.Pendubot.PendubotFlashPanel.<init>(PendubotFlashPanel.java:25)
 at control.Pendubot.PendubotFlashControl.<init>(PendubotFlashControl.java:42)
 ... 44 more
Caused by: java.net.SocketException: Connection reset
 at java.net.SocketInputStream.read(Unknown Source)
 at java.io.BufferedInputStream.fill(Unknown Source)
 at java.io.BufferedInputStream.read1(Unknown Source)
 at java.io.BufferedInputStream.read(Unknown Source)
 at java.io.ObjectInputStream$PeekInputStream.read(Unknown Source)
 at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
 at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
 at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
 at java.io.ObjectInputStream.<init>(Unknown Source)
 at chrriis.dj.nativeswing.swtimpl.OutProcessMessagingInterface.openChannel(OutProcessMessagingInterface.java:62)
 ... 53 more

 

 可以看到红色的。这个异常怎么解决呢?

 解决办法 分两个方面:

一、在eclipse开发环境下调试时:

http://www.developer.com/java/other/article.php/10936_3330861_2/SWT-Programming-with-Eclipse.htm

摘录如下:

To run the application without using Eclipse, the swt.jar library must be in your classpath, and the java.library.path enviroment variable must be set properly. Depending on the host platform, the appropriate native library file must be available. For the Windows platform, you can do the following to make the native library configuration for your application:

  1. Put swt.dll in the same directory as the program.
  2. Put swt.dll in the JAVA_HOME\bin\ directory.
  3. Put swt.dll in the c:\windows\system32 directory.

javac classpath c:\swt\swt.jar HelloWorld.java
Java classpath c:\swt\swt.jar;. Djava.library.path=c:\swt HelloWorld
The java.library.path is the required environment variable for the JNI. If you don't set this environment, your DLL class is not accessible. In that case, the application cannot run properly and throws an exception.

二、当导出RCP产品时:

有两种办法,本人采用第二种,比较简单。

1、在安装过程中把dll放在java library path下  ,即JAVA_HOME\bin\ directory.

2、导出产品之后,直接把那个dll放在根目录下。

 

当然也许还有更好的办法,希望拍砖!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
org.eclipse.aether.resolution.ArtifactResolutionException: Failure to find jre:jre:zip:call:1.0.0-SNAPSHOT in http://download.eclipse.org/recommenders/models/oxygen/ was cached in the local repository, resolution will not be reattempted until the update interval of models has elapsed or updates are forced at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:453) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:255) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:232) at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:303) at org.eclipse.recommenders.models.ModelRepository.resolveInternal(ModelRepository.java:193) at org.eclipse.recommenders.models.ModelRepository.resolve(ModelRepository.java:172) at org.eclipse.recommenders.internal.models.rcp.EclipseModelRepository.resolve(EclipseModelRepository.java:168) at org.eclipse.recommenders.internal.models.rcp.DownloadModelArchiveJob.run(DownloadModelArchiveJob.java:76) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find jre:jre:zip:call:1.0.0-SNAPSHOT in http://download.eclipse.org/recommenders/models/oxygen/ was cached in the local repository, resolution will not be reattempted until the update interval of models has elapsed or updates are forced at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:240) at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:215) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:594) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:512) at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:430) ... 8 more
最新发布
07-12

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值