在Mac上启动我的Java应用程序(swt)时出错

时间:2011-11-04 07:05:16

标签: java macos cross-platform swt

我正在Windows 7(32位)机器上开发一个java应用程序。我在我的应用程序中使用了SWT并通过Java Web Start运行它。它在Windows 7上工作正常,但是当我尝试在MAC OSX 10.6.8上运行它时,它无法启动我的应用程序。我在我的库中添加了“swt-3.7M5-win32-win32-x86.jar”。 我在我的jnlp文件中添加了以下行,以便在32位JVM上运行它:

<j2se version="1.6+" java-vm-args="-d32" href="http://java.sun.com/products/autodl/j2se"/>

但仍无效。

抛出以下错误:

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.javaws.Launcher.executeApplication(Launcher.java:1914)
at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1847)
at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1609)
at com.sun.javaws.Launcher.run(Launcher.java:138)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-win32-3721 in java.library.path
no swt-win32 in java.library.path
Can't load library: /Users/Rajivj/.swt/lib/macosx/x86/libswt-win32-3721.jnilib
Can't load library: /Users/Rajivj/.swt/lib/macosx/x86/libswt-win32.jnilib

at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.eclipse.swt.graphics.Device.<clinit>(Unknown Source)
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$InProcess.initialize(SWTNativeInterface.java:559)
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface$InProcess.access$2(SWTNativeInterface.java:558)
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.initialize_(SWTNativeInterface.java:238)
at chrriis.dj.nativeswing.swtimpl.NativeInterface.initialize(NativeInterface.java:71)
at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.open_(SWTNativeInterface.java:316)
at chrriis.dj.nativeswing.swtimpl.NativeInterface.open(NativeInterface.java:100)
at rtlmatrixcloud.Main.main(Main.java:32)
... 9 more

有谁能告诉我如何解决这个问题?

任何帮助都将不胜感激。

由于 SONAL

1 个答案:

答案 0 :(得分:0)

这是根本问题:

Caused by: java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-win32-3721 in java.library.path
no swt-win32 in java.library.path
Can't load library: /Users/Rajivj/.swt/lib/macosx/x86/libswt-win32-3721.jnilib
Can't load library: /Users/Rajivj/.swt/lib/macosx/x86/libswt-win32.jnilib

首先检查这些lib文件是否存在。我相信他们是因为它说“UnsatisfiedLinkError”并且没有抱怨找不到文件。在这种情况下,请检查您的SWT安装。看来这些库与您的JVM不匹配。通常,当例如32位JVM尝试调用64位库时会抛出此类异常,反之亦然。