ubuntu12.04下eclipse无法打开:Could not load SWT library

ubuntu 12.04下,先安装配置了JAVA JDK7后,再使用软件中心安装eclipse后,打开时出现错误。察看日志可知原因为相关库文件位置信息的丢失,建立对应库文件链接即可解决问题。错误日志如下:

!SESSION 2012-07-11 19:42:52.270 ———————————————–
eclipse.buildId=I20110613-1736
java.version=1.7.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=zh_CN
Command-line arguments:  -os linux -ws gtk -arch x86

!ENTRY org.eclipse.osgi 4 0 2012-07-11 19:43:00.316
!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/lzw/.swt/lib/linux/x86/libswt-gtk-3740.so
    Can't load library: /home/lzw/.swt/lib/linux/x86/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)

解决方法:

首先执行如下命令更改要使用的java JDK版本:

#update-alternatives –config java

选择你正确的java版本(当你系统中有多个jdk版本的情况下)
 
接着建立如下库文件的软连接

libswt-atk-gtk-3740.so -> /usr/lib/jni/libswt-atk-gtk-3740.so
libswt-awt-gtk-3740.so -> /usr/lib/jni/libswt-awt-gtk-3740.so
libswt-gtk-3740.so -> /usr/lib/jni/libswt-gtk-3740.so
libswt-pi-gtk-3740.so -> /usr/lib/jni/libswt-pi-gtk-3740.so

以上库文件软连接存放地址:
X86_64(64位):
~/.swt/lib/linux/x86_64
X86(32位):
~/.swt/lib/linux/x86

即执行如下命令:

cd ~/.swt/lib/linux/x86_64/
ln -s /usr/lib/jni/libswt-atk-gtk-3740.so libswt-atk-gtk-3740.so
ln -s /usr/lib/jni/libswt-awt-gtk-3740.so libswt-awt-gtk-3740.so
ln -s /usr/lib/jni/libswt-gtk-3740.so libswt-gtk-3740.so
ln -s /usr/lib/jni/libswt-pi-gtk-3740.so libswt-pi-gtk-3740.so

或者复制这四个文件到对应目录也可。执行命令:

X86_64(64位):

#cp /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64
 

X86(32位):
 

#cp /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86

最后再打开eclipse,即可正常使用

点赞 (0)
  1. tui56说道:

    tui56论坛-王宝臣来看看。呵呵。博客大全已经收录贵站博客……欢迎加入bbs.tui56.com SEO论坛!tui56论坛不求盈利……只求帮助更多朋友了解学习seo……希望通过这个圈子认识更多的朋友!已做好10年发展准备。www.tui56.com 续费到2022年!欢迎你的到来!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.