Home » Errors & Failures » Package Installation Error » Fixed: java.lang.UnsatisfiedLinkError: Could not load SWT library

Fixed: java.lang.UnsatisfiedLinkError: Could not load SWT library

The error like “Can’t load library: /usr/lib/jni/libswt-cairo-gtk” or “java.lang.UnsatisfiedLinkError: Could not load SWT library” can be resolved by installing necessary package as mentioned in this post.

Actual Error as seen on Terminal

(java:30519): Gdk-WARNING **: 11:52:37.840: The GDK_NATIVE_WINDOWS environment variable is not supported in GTK3.
See the documentation for gdk_window_ensure_native() on how to get native windows.

shutting down due to uncaught exception
Could not load SWT library. Reasons:
no swt-cairo-gtk-4919 in java.library.path
no swt-cairo-gtk in java.library.path
Can't load library: /usr/lib/jni/libswt-cairo-gtk-4919.so
Can't load library: /usr/lib/jni/libswt-cairo-gtk.so

java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-cairo-gtk-4919 in java.library.path
no swt-cairo-gtk in java.library.path
Can't load library: /usr/lib/jni/libswt-cairo-gtk-4919.so
Can't load library: /usr/lib/jni/libswt-cairo-gtk.so


at org.eclipse.swt.internal.Library.loadLibrary(Library.java:334)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:242)
at org.eclipse.swt.internal.cairo.Cairo.<clinit>(Cairo.java:28)
at org.eclipse.swt.widgets.Display.createDisplay(Display.java:1059)
at org.eclipse.swt.widgets.Display.create(Display.java:1025)
at org.eclipse.swt.graphics.Device.<init>(Device.java:179)
at org.eclipse.swt.widgets.Display.<init>(Display.java:590)
at org.eclipse.swt.widgets.Display.<init>(Display.java:581)
at org.eclipse.swt.widgets.Display.getDefault(Display.java:2450)

Can be solved as,

$ sudo apt-get install -y libswt-cairo-gtk-4-jni

Once, above installation is successful, you can try the application which you wanted to work with and it should work fine now.

Leave a Comment