I’ve been familiarizing myself with the Java Developer’s IDE Eclipse in Linux Mint. The IDE feels good. Clean, lots of features. Here’s a mini screenshot of Eclipse.
I loaded it on my Desktop PC running Linux Mint 15 and was up and coding in minutes. On my Linux Mint laptop it was another story. When creating a simple Hello World app with Eclipse’s Standard Widget Toolkit (or SWT) I kept encountering
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-gtk-4332 in java.library.path
no swt-gtk in java.library.path
Can’t load library: /home/vimal/.swt/lib/linux/x86/libswt-gtk-4332.so
Can’t load library: /home/vimal/.swt/lib/linux/x86/libswt-gtk.so
There were several issues at play on my laptop for some reason. One was that I was using OpenJDK, but unfortunately Eclipse likes the Oracle Java better (which includes a JDK and a JRE.) Time to install Oracle Java. There are some ugly tutorials out there on how to move from OpenJDK to Oracle Java, so beware. I went with a guide from Web Upd8 on installing Oracle Java 7 using the PPA Repository and it was pretty painless.
You’ll see a number of suggestions to copy or soft link the /usr/lib/jni/ GTK files to ~/.swt/lib/linux/x86_64/ (for 64-bit machines, /x86 for 32-bit), but as Obi-Wan would say, those are not the Shared Object library files you are looking for, even after installing Oracle Java 7 or the Standard Widget Toolkit for GTK+ Java library from the PPA Repository.
But it’s true that Eclipse is looking for shared GTK library files in ~/.swt/lib/linux/x86_64/ so that’s what we’re going to feed it. Fortunately Eclipse has already created them in the standard SWT package in the Eclipse workspace, for me in ~/eclipse/workspace/org.eclipse.swt.gtk.linux.x86_64.
I don’t know why this was required, but here was my fix: I copied the GTKs in this SWT library to ~/.swt/lib/linux/x86_64/. Bam! There it was. Error Free Eclipse Standard Widget Toolkit coding in Linux Mint, on my desktop AND on my laptop.