eclipse 线程“main”中的异常 java.lang.UnsatisfiedLinkError:无法加载 SWT 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2982883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:48:41  来源:igfitidea点击:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library

javaeclipseubuntu

提问by javadahut

What is the reason for the following error I am having:

我遇到以下错误的原因是什么:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library.

线程“main”中的异常 java.lang.UnsatisfiedLinkError:无法加载 SWT 库。

I am using Eclipse 3.5 SE on Ubuntu 9.04 Jaunty.

我在 Ubuntu 9.04 Jaunty 上使用 Eclipse 3.5 SE。

How can I resolve this error?

我该如何解决这个错误?

回答by Victor Sergienko

I had same problem with Oracle Java 7 and Eclipse on 32-bit system.

我在 32 位系统上使用 Oracle Java 7 和 Eclipse 时遇到了同样的问题。

libswt-gtk-3.6-javaand libswt-gtk-3.6-jniwere already installed. What helped:

libswt-gtk-3.6-java并且libswt-gtk-3.6-jni已经安装。什么帮助

cd ~/.swt/lib/linux/x86
ln -s /usr/lib/jni/* .

Maybe this can be done reconfiguring Java alternatives or what.

也许这可以通过重新配置 Java 替代品或什么来完成。

回答by Scott Severance

I believe Mikolaj Lechtanski's workaroundis more elegant.

我相信Mikolaj Lechtanski 的解决方法更优雅。

create or edit /etc/eclipse.ini

Paste inside:

-vmargs
-Djava.library.path=/usr/lib/jni

exit

make sure the file is readable:

sudo chmod 755 /etc/eclipse.ini

创建或编辑 /etc/eclipse.ini

粘贴在里面:

-vmargs
-Djava.library.path=/usr/lib/jni

出口

确保文件可读:

sudo chmod 755 /etc/eclipse.ini

回答by Romain Hippeau

This means the native libraries could not be found.
Either you have 32-bit libraries and you are running on a 64-bit machine or vice-versa.
also make sure you have the -Djava.library.path=set properly

这意味着无法找到本机库。
要么你有 32 位库并且你在 64 位机器上运行,反之亦然。
还要确保你有-Djava.library.path=正确的设置

See this page on how to run outside of eclipse

有关如何在 eclipse 之外运行的信息,请参阅此页面

回答by Jesper

What versions of Java and Eclipse are you using, and are they 32-bit or 64-bit, and how did you install them?

您使用的是什么版本的 Java 和 Eclipse,它们是 32 位还是 64 位,您是如何安装它们的?

Eclipse uses its own GUI library called SWT (it doesn't use Java's AWT or Swing), and it needs some native (non-Java) libraries for this. If you have 32-bit Java installed, you need 32-bit Eclipse; if you have 64-bit Java installed, you need 64-bit Eclipse (note, the Eclipse downloadspage has 32-bit and 64-bit versions for Linux).

Eclipse 使用自己的名为 SWT 的 GUI 库(它不使用 Java 的 AWT 或 Swing),为此它需要一些本机(非 Java)库。如果安装了 32 位 Java,则需要 32 位 Eclipse;如果您安装了 64 位 Java,则需要 64 位 Eclipse(注意,Eclipse 下载页面有适用于 Linux 的 32 位和 64 位版本)。

(Note that it doesn't depend on whether your Linux OS is 32-bit or 64-bit, but on whether your Java is).

(请注意,这不取决于您的 Linux 操作系统是 32 位还是 64 位,而取决于您的 Java 是否是)。

回答by Stephen Niedzielski

I had a similar issue when running Eclipse remotely on a server via a "ssh -X" tunnel. I resolved it using "sudo apt-get install libswt-gtk-3.6-java" on the server.

通过“ssh -X”隧道在服务器上远程运行 Eclipse 时,我遇到了类似的问题。我在服务器上使用“sudo apt-get install libswt-gtk-3.6-java”解决了它。

回答by Jens Erat

Happened to me when starting some GUI java application on a headless server using X11 forwarding while only having openjdk-7-jre-headlessinstalled. Installing the full jre solved the problem:

在仅openjdk-7-jre-headless安装了X11 转发的无头服务器上启动一些 GUI java 应用程序时发生在我身上。安装完整的jre解决了这个问题:

apt-get install openjdk-7-jre

回答by James Testa

I ended up doing

我最终做了

 cd ~/.swt/lib/macosx/x86_64
 ln -s /usr/lib/java/* .

which fixed that problem.

这解决了这个问题。