305

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

3
  • 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/...)? Commented Apr 15, 2012 at 21:05
  • Did you install libswt-java-gtk3? Commented Apr 15, 2012 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. Commented Oct 17, 2013 at 13:07

13 Answers 13

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/
10
  • 5
    I executed that command exactly as you have it and it worked! Ubuntu 12.04 with Oracle Java 7 Commented Apr 27, 2012 at 18:52
  • 2
    I'll prefer this method as I have to use Oracle Java 7 for a project
    – rojanu
    Commented Apr 27, 2012 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
    Commented Jun 8, 2012 at 22:49
  • 3
    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
    Commented Mar 27, 2013 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! Commented Feb 3, 2014 at 21:47
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.

4
  • 7
    but what if you'd like to use Oracle Java with eclipse, and not Open JDK, how could one do that? thanks!
    – ultrajohn
    Commented Jun 14, 2012 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
    Commented Jan 14, 2013 at 22:28
  • Worked for me for linux mint maya.
    – rshahriar
    Commented Apr 1, 2013 at 6: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
    Commented May 28, 2013 at 6:02
44

Simply specify the path to the libraries:

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

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.

3
  • 2
    After installing jni. I copied files using this command for 32 bit: ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86/
    – padman
    Commented Dec 8, 2014 at 11:09
  • 4
    In my case, I needed sudo apt-get install libswt-gtk-4-jni libswt-gtk-4-java
    – aleixrocks
    Commented Jun 11, 2019 at 8: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
    Commented Dec 11, 2020 at 12:52
11

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
1
  • 2
    I am using openjdk-17-jdk, and just doing apt install libswt-gtk-4-jni did the trick. Thanks!
    – davekats
    Commented Oct 28, 2023 at 2:22
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

1
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/
3

On redhat7 :

yum install gtk2 libXtst xorg-x11-fonts-Type1

did the job, because of a swt dependency.

found here

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.

1
  • 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? Commented Feb 25, 2020 at 15:33
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.

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.

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.