304

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

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
TomRichardson
  • 5,933
  • 5
  • 27
  • 30
  • 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/...)? – Marko Topolnik Apr 15 '12 at 21:05
  • Did you install libswt-java-gtk3? – Federico Vera Apr 15 '12 at 21:30
  • 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. – android.weasel Oct 17 '13 at 13:07

14 Answers14

662

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/
user unknown
  • 35,537
  • 11
  • 75
  • 121
Scott
  • 7,983
  • 2
  • 26
  • 41
  • 5
    I executed that command exactly as you have it and it worked! Ubuntu 12.04 with Oracle Java 7 – Michael Allan Jackson Apr 27 '12 at 18:52
  • 2
    I'll prefer this method as I have to use Oracle Java 7 for a project – rojanu Apr 27 '12 at 19:41
  • 2
    Thank you. My path was slightly different but this fixed it for me. `ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86/` – Art Jun 08 '12 at 22:49
  • ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64/ for 12.04 64-bit – Andrew Sledge Jun 12 '12 at 19:08
  • 2
    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? – jonhopkins Mar 27 '13 at 21:47
  • 2
    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! – PoweredByRice Feb 03 '14 at 21:47
  • i am facing similar error in linux 64 bit, can anybody check this question, http://stackoverflow.com/questions/21980558/facing-trouble-launching-spoon-sh-on-amazon-ec2-linux – Helping Hand.. Feb 28 '14 at 07:20
  • For unbuntu 12.04 on MacMini (PPC) the command is ln -s /usr/lib/jni/libswt* ~/.swt/lib/linux/ppc – Haqa Mar 05 '14 at 19:40
  • This was the solution for the error caused by using Oracle Java 9 as default on Ubuntu 12.04 when installing Eclipse from Software Center or apt-get repository. – JohnMerlino May 13 '14 at 03:42
  • I executed the command exactly the way its written here but i get this error: `ln: target ‘/home/latinoheat/.swt/lib/linux/x86_64/’ is not a directory: No such file or directory` – Yonela Nuba Feb 25 '20 at 15:24
54

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.

TomRichardson
  • 5,933
  • 5
  • 27
  • 30
  • 7
    but what if you'd like to use Oracle Java with eclipse, and not Open JDK, how could one do that? thanks! – ultrajohn Jun 14 '12 at 21:50
  • 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 – Wudong Jan 14 '13 at 22:28
  • Worked for me for linux mint maya. – rshahriar Apr 01 '13 at 06:45
  • 1
    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! – venzen May 28 '13 at 06:02
44

Simply specify the path to the libraries:

echo "-Djava.library.path=/usr/lib/jni/" >> /etc/eclipse.ini
dzlatkov
  • 646
  • 6
  • 7
  • 2
    Seems that this is the cleanest solution. – mspanc Apr 19 '13 at 20:50
  • 1
    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 – venzen May 28 '13 at 05:55
  • 2
    Worked for me on Ubuntu 64-bit Cleanest solution indeed, I recommend anyone pick this solution instead of creating the symlinks – Toughy Oct 15 '13 at 09:25
  • this is the one to use if your using oracle java 7 and not open JDK – James Kirkby Feb 01 '14 at 13:17
  • The most voted answer works, but not for when you "sudo eclipse". This answer is superior, it works in all cases! – PoweredByRice Feb 03 '14 at 23:17
15

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.

Trenton
  • 11,678
  • 10
  • 56
  • 60
  • 2
    After installing jni. I copied files using this command for 32 bit: ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86/ – padman Dec 08 '14 at 11:09
  • 4
    In my case, I needed sudo apt-get install libswt-gtk-4-jni libswt-gtk-4-java – aleixrocks Jun 11 '19 at 08:18
  • @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). – Frans Dec 11 '20 at 12:52
8

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
ATorras
  • 4,073
  • 2
  • 32
  • 39
5
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

sherif
  • 2,282
  • 19
  • 21
  • i am facing similar error in linux 64 bit, can you check this question, http://stackoverflow.com/questions/21980558/facing-trouble-launching-spoon-sh-on-amazon-ec2-linux – Helping Hand.. Feb 28 '14 at 07:20
3

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/
Frank Schmitt
  • 30,195
  • 12
  • 73
  • 107
leroneb
  • 75
  • 7
3

On redhat7 :

yum install gtk2 libXtst xorg-x11-fonts-Type1

did the job, because of a swt dependency.

found here

user1767316
  • 3,276
  • 3
  • 37
  • 46
2

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.

user1460856
  • 501
  • 4
  • 3
  • 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? – Yonela Nuba Feb 25 '20 at 15:33
2

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.

lumpynose
  • 967
  • 4
  • 12
1

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.

lancha90
  • 5,064
  • 2
  • 17
  • 9
0

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.

Martin B.
  • 81
  • 5
0

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
user1767316
  • 3,276
  • 3
  • 37
  • 46
0

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".

Shyam Gupta
  • 489
  • 4
  • 8