简体   繁体   English

SWT + Maven + Eclipse = java.lang.UnsatisfiedLinkError:swt.library.path中没有swt-carbon-3346或swt-carbon

[英]SWT + Maven + Eclipse = java.lang.UnsatisfiedLinkError: no swt-carbon-3346 or swt-carbon in swt.library.path

I am trying to get a hello world SWT application going: 我想要一个hello world SWT应用程序:

public static void main(String args[]) throws IOException{
    Display display = new Display ();
    Shell shell = new Shell(display);
    shell.open ();
    while (!shell.isDisposed ()) {
        if (!display.readAndDispatch ()) display.sleep ();
    }
    display.dispose ();
}

But I keep getting the following exception. 但我一直得到以下例外。 I have the macosx version of org.eclipse.swt.carbon being used with eclipse/maven. 我有与eclipse / maven一起使用的org.eclipse.swt.carbon的macosx版本。 Has anyone seen this before? 谁看过这个吗?

Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-carbon-3346 or swt-carbon in swt.library.path, java.library.path or the jar file
    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:219)
    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:151)
    at org.eclipse.swt.internal.C.<clinit>(C.java:21)
    at org.eclipse.swt.widgets.Display.createDisplay(Display.java:943)
    at org.eclipse.swt.widgets.Display.create(Display.java:937)
    at org.eclipse.swt.graphics.Device.<init>(Device.java:119)
    at org.eclipse.swt.widgets.Display.<init>(Display.java:749)
    at org.eclipse.swt.widgets.Display.<init>(Display.java:740)
    at com.wuntee.aat.command.adb.LogCat.main(LogCat.java:30)

SWT is implemented using native UI libraries - in this case, the Mac Carbon libraries - and requires some JNI code to marshal the SWT calls to the native Carbon calls. SWT是使用本机UI库(在本例中为Mac Carbon库)实现的,并且需要一些JNI代码来编组对本机Carbon调用的SWT调用。 Loading JNI libraries is a little bit different than normal classloading (the dynamic libraries must first be loaded with System#loadLibrary ). 加载JNI库与正常的类加载有点不同(动态库必须首先加载System#loadLibrary )。

First, if you're on a 64 bit machine, make sure that you're passing the -d32 argument to the JRE. 首先,如果您使用的是64位计算机,请确保将-d32参数传递给JRE。 (ie, java -d32 MyTestClass ). (即java -d32 MyTestClass )。 The Carbon SWT libraries are 32 bit only and will not load on a 64 bit runtime. Carbon SWT库仅为32位,不会在64位运行时加载。

By default, SWT tries to load the .jnilib dynamic libraries from a JAR file in your classpath - the library libswt-carbon-3346.jnilib should be in your org.eclipse.swt.carbon.macosx... JAR. 默认情况下,SWT尝试从类路径中的JAR文件加载.jnilib动态库 - 库libswt-carbon-3346.jnilib应该在您的org.eclipse.swt.carbon.macosx... JAR中。 SWT will try to unzip this jnilib from your JAR into a temporary location and load that. SWT会尝试将这个jnilib从您的JAR解压缩到一个临时位置并加载它。

If it can't do this for whatever reason ( java.io.tmpdir isn't writable, for example) then this will fail. 如果由于某种原因它无法执行此操作(例如, java.io.tmpdir不可写),那么这将失败。 To work around this, you should extract libswt-carbon-3346.jnilib from the org.eclipse.swt.carbon.macosx JAR and follow the instructions that the exception provided. 要解决此问题,您应该从org.eclipse.swt.carbon.macosx JAR中提取libswt-carbon-3346.jnilib ,并按照提供的异常的说明进行操作。 (For example, set swt.library.path to the location of that jnilib.) (例如,将swt.library.path设置swt.library.path的位置。)

Unrelated to your actual question: you're using SWT 3.3. 与您的实际问题无关:您使用的是SWT 3.3。 A lot of changes have been made since then, including the (likely preferable) Cocoa support. 自那时以来已经做了很多改变,包括(可能更可取的)Cocoa支持。 Upgrading to the newest SWT libraries in the newest Eclipse may be very helpful. 在最新的Eclipse中升级到最新的SWT库可能会非常有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.UnsatisfiedLinkError:java.library.path 中没有 swt-pi-gtk-2024 或 swt-motif-2024 - java.lang.UnsatisfiedLinkError: no swt-pi-gtk-2024 or swt-motif-2024 in java.library.path 线程“ main”中的异常java.lang.UnsatisfiedLinkError:java.library.path中没有swt-pi-gtk-3139 - Exception in thread “main” java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3139 in java.library.path 线程“main”中的异常java.lang.UnsatisfiedLinkError:无法加载SWT库 - Exception in thread “main” java.lang.UnsatisfiedLinkError: Could not load SWT library Java SWT在“主”线程中具有maven异常java.lang.NoClassDefFoundError:org / eclipse / swt / widgets / Composite - Java SWT with maven Exception in thread “main” java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Composite java.lang.UnsatisfiedLinkError:无法在Windows中的64位JVM上加载32位SWT库 - java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM in windows java.lang.UnsatisfiedLinkError:运行可视化定制程序的“ no swt-win32-4623” - java.lang.UnsatisfiedLinkError: “no swt-win32-4623” running Visualization Customizer Eclipse中的Java_swt - Java_swt in eclipse JAVA SWT轻松日食 - JAVA SWT with easy eclipse Eclipse的Java SWT自动完成 - Java SWT autocomplete for Eclipse java.lang.UnsatisfiedLinkError:无法在Windows x86机器上的32位JVM上加载64位SWT库 - java.lang.UnsatisfiedLinkError: Cannot load 64-bit SWT libraries on 32-bit JVM in Windows x86 machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM