ChatGPT解决这个技术问题 Extra ChatGPT

Eclipse cannot load SWT libraries

Every time I try to open Eclipse in Ubuntu 12.04 I get an Unsatisfied Link Error and it will not open. I have recently installed the java JDK and Android SDK, could this be the problem? I followed this tutorial.

Here is the log info:

!SESSION 2012-04-15 21:05:46.902 -----------------------------------------------
eclipse.buildId=I20110613-1736
java.version=1.7.0
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_GB
Command-line arguments:  -os linux -ws gtk -arch x86_64

!ENTRY org.eclipse.osgi 4 0 2012-04-15 21:05:47.885
!MESSAGE Application error
!STACK 1
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
no swt-gtk-3740 in java.library.path
no swt-gtk in java.library.path
Can't load library: /home/tom/.swt/lib/linux/x86_64/libswt-gtk-3740.so
Can't load library: /home/tom/.swt/lib/linux/x86_64/libswt-gtk.so

at org.eclipse.swt.internal.Library.loadLibrary(Library.java:285)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:194)
at org.eclipse.swt.internal.C.<clinit>(C.java:21)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:132)
at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:695)
at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:161)
at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay(IDEApplication.java:153)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:95)
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:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

I have tried uninstalling and reinstalling, and removing the ~/.eclipse directory but it still doesn't work

I must say your library path looks odd. Shouldn't those .so files be somewhere within the eclipse/plugins folder, within an exploded jar? Do you even have such a directory (~/.swt/lib/...)?
Did you install libswt-java-gtk3?
Although this is answered below, it seems this remains a bug in Ubuntu's installation system that should be raised, because it persists even if I uninstall and reinstall eclipse using aptitude/apt-get. If there's a link to that issue, it would be good to provide it here so folks could upvote it.

u
user unknown

on my Ubuntu 12.04 32 bit. I edit the command to:

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

And on Ubuntu 12.04 64 bit try:

ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64/

I executed that command exactly as you have it and it worked! Ubuntu 12.04 with Oracle Java 7
I'll prefer this method as I have to use Oracle Java 7 for a project
Thank you. My path was slightly different but this fixed it for me. ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86/
This is the second time I've had to do this: once on my work computer a few months ago, and just now on my home computer, both times after months of using Eclipse without a single problem. Is there any particular reasons why the swt libraries would just disappear?
This is real life saver! Note whoever on ARM (like me running Eclipse on Chromebook) should replace "x86" with "arm" otherwise it won't work!
T
TomRichardson

SOLVED:

Because I had installed the Oracle Java 7 it had changed the default Java to Oracle Java 7, however it needed to be the Open JDK.

To fix, open up terminal and type

sudo update-alternatives --config java

This brings up a list of the different types of Java. Simply select the Open JDK.


but what if you'd like to use Oracle Java with eclipse, and not Open JDK, how could one do that? thanks!
is this because Oracle Java 7 dont look for native library in the Jars anymore? I have a same problem on windows with Java 7 as well. the swt program used to be work just fine
Worked for me for linux mint maya.
Of course, if you prefer FOSS, OpenJDK is the platform of choice, but (as usual with these corporate troglodytes) Oracle imposes certain hooks in their version that prevents porting of some apps (and most java webstart apps) between java platforms. This defeats the main objective of Java, namely portability, which is why they are shooting themselves in the foot by practicing vendor lock-in... Long Live the Python! Long Live!
d
dzlatkov

Simply specify the path to the libraries:

echo "-Djava.library.path=/usr/lib/jni/" >> /etc/eclipse.ini

Seems that this is the cleanest solution.
Agree, cleanest and this method will permanently avoid the error on an Ubuntu system that is prone to Java version changes - given the side-effect of OpenJDK upgrades to reconfigure java related file locations
Worked for me on Ubuntu 64-bit Cleanest solution indeed, I recommend anyone pick this solution instead of creating the symlinks
this is the one to use if your using oracle java 7 and not open JDK
The most voted answer works, but not for when you "sudo eclipse". This answer is superior, it works in all cases!
T
Trenton

In my case, I was missing the /usr/lib/jni directory entirely. Fixed by

sudo apt-get install libswt-gtk-3-jni libswt-gtk-3-java

No need to symlink afterwards. Eclipse started normally.


After installing jni. I copied files using this command for 32 bit: ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86/
In my case, I needed sudo apt-get install libswt-gtk-4-jni libswt-gtk-4-java
@padman Copying files that were installed by package management (APT in this case) is not a good idea. The copied files won't be under package management and you risk getting all kinds of other errors later on when the files under package management get upgraded. Instead, find a way to point your Eclipse to the correct location of these libraries (see dzlatkov 's answer above).
A
ATorras

For Windows Subsystem for Linux (WSL) you'll need

apt install libswt-gtk-4-jni

If you don't have an OpenJDK 8 you'll also need

apt install openjdk-8-jdk

s
sherif
Can't load library: /home/tom/.swt/lib/linux/x86_64/libswt-gtk-3740.so
Can't load library: /home/tom/.swt/lib/linux/x86_64/libswt-gtk.so

looks like the libraries should be at .swt/lib/linux/x86_64/ if there are not there you can try this command:

locate  libswt-gtk.so

this should find the libraries copy the entire directory to /home/tom/.swt/lib/linux/x86_64


i am facing similar error in linux 64 bit, can you check this question, stackoverflow.com/questions/21980558/…
F
Frank Schmitt

I agree with Scott, what he listed worked. However just running it from any directory did not work. I had to cd to the /home/*/.swt/lib/linux/x86_64/ 0 files

directory first and then run the link command:

For 32 bit:

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

And on Ubuntu 12.04 64 bit:

ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64/

u
user1767316

On redhat7 :

yum install gtk2 libXtst xorg-x11-fonts-Type1

did the job, because of a swt dependency.

found here


u
user1460856

If you start eclipse using oracle java, then eclipse might fail in finding native libraries like SWT or SVN libraries. The SWT-JNI libraries are located in /usr/lib/jni/ and the SVN-JNI libraries are located in /usr/lib/x86_64-linux-gnu/jni/.

Instead of starting eclipse with the command

eclipse

you can use the command

env LD_LIBRARY_PATH=/usr/lib/jni/:/usr/lib/x86_64-linux-gnu/jni/:$LD_LIBRARY_PATH eclipse

to pass the environment variable LD_LIBRARY_PATH to eclipse. Eclipse will find the native libraries and will run properly.


This gives me this error Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0 WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.eclipse.osgi.internal.baseadaptor.BaseStorage (file:/usr/lib/eclipse/plugins/org.eclipse.osgi_3.8.1.dist.jar) to method java.net.URLClassLoader.addURL(java.net.URL) WARNING: Please consider reporting this to the maintainers of org.eclipse.osgi.internal.baseadaptor.BaseStorage How can I solve it?
l
lumpynose

I'm on debian linux amd64. I installed oracle's Java 11 from oracle's java download page. Installed eclipse from eclipse.org. Running eclipse produced the "cannot load swt" error. I followed ATorras's advice and did apt install libswt-gtk-4-jni (which also installed a ton of other things) and after that eclipse started. Although it started I did get the following errors/warnings:

org.eclipse.m2e.logback.configuration: The org.eclipse.m2e.logback.configuration bundle was activated before the state location was initialized.  Will retry after the state location is initialized.
SWT SessionManagerDBus: Failed to connect to org.gnome.SessionManager: Failed to execute child process “dbus-launch” (No such file or directory)
SWT SessionManagerDBus: Failed to connect to org.xfce.SessionManager: Failed to execute child process “dbus-launch” (No such file or directory)
org.eclipse.m2e.logback.configuration: Logback config file: /home/rusty/eclipse-workspace/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.16.0.20200318-1040.xml
org.eclipse.m2e.logback.configuration: Initializing logback
SWT Webkit: Warning, You are using an old version of webkitgtk. (pre 2.4) BrowserFunction functionality will not be avaliable
SWT WebKit: error initializing DBus server, dBusServer == 0
SWT.CHROMIUM style was used but chromium.swt gtk (or CEF binaries) fragment/jar is missing.

I think I can ignore most if not all of that. I'm doing an ssh into the linux box using mobaXterm on my windows pc, so it's displaying its window on my pc. My linux box is headless.


l
lancha90

I came across this error when tried to start 32-bit build of Eclipse under 64-bit linux. The problem was solved after installing ia32-libs package.


M
Martin B.

Please make sure that your home partition is mounted with executable permissions. That is the default, but if you happen to mount it without exec option, you will get this error.


u
user1767316

A possibly more generic method is to:

install non-headless version of the openjdk,

install, run and close eclipse.

uninstall the openjdk

install oracle's JDK


S
Shyam Gupta

I installed the JDK 32 bit because of that I am getting the errors. After installing JDK 64 bit http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html jdk-8u131-linux-x64.tar.gz(please download the 64 version) and download 64 bit "eclipse-inst-linux64.tar.gz".


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now