2013年1月15日 星期二

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
share|improve this question

54% accept rate
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? – Fido Apr 15 '12 at 21:30
Robert Harvey is a power-tripping douche. Why is this question closed? It is clearly a valid question and there is clearly a valid answer with over 100 upvotes. The answer helped me and many other Ubuntu users. Please reopen the question. – Andrew Mao Sep 29 '12 at 1:51
@AndrewMao I sometimes wonder how it is possible that a website is deliberately ignoring and even insulting it's users this way and survive. It seems any question or answer that gets over 100 votes immediately becomes suspect and terminated. Smells like 1984 to me. – owlstead Oct 15 '12 at 2:17
@AndrewMao Let's not get personal. Moderators are only human, they can make mistakes too. Voted to re-open.– S.L. Barth Oct 17 '12 at 9:26
feedback

4 Answers

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/
share|improve this answer
3 
This was my problem and this is what fixed it. Thanks! – Dave Apr 27 '12 at 13:26
2 
I executed that command exactly as you have it and it worked! Ubuntu 12.04 with Oracle Java 7 – majgis 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
+1 This just worked. I needed Eclipse to use Sun Java 6. – superxor May 18 '12 at 15:08
5 
this should be the answer. Thank you – Thai Tran Aug 16 '12 at 4:35
show 7 more comments
feedback
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.
share|improve this answer
5 
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 9 hours ago
feedback
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
share|improve this answer
feedback
Solved my problem by following this procedure on Ubuntu 12.04 64:
ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64/
In case it is 32 bit
ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86/
share|improve this answer
-1. This answer is exactly the same the one posted by Scott 8 months earlier... – caspase Jan 9 at 15:14

沒有留言: