Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Eclipse SWT Browser component running on Ubuntu 11.04 (Natty Narwhal) with Webkit?

I use the SWT Browser control in my Eclipse RCP application. On Linux Ubuntu 10.10 this depends on the user having installed xulrunner-1.9.2. This works fine.

However, on Ubuntu 11.04 I find that it ships by default with xulrunner-2.0. The SWT Browser does not support this. See http://bugs.eclipse.org/bugs/show_bug.cgi?id=327696 and http://bugs.eclipse.org/bugs/process_bug.cgi

So rather than ask the user to install xulrunner-1.9.2 I want to get the SWT Browser to run with WebKitGTK as per the instructions on the SWT FAQ - http://www.eclipse.org/swt/faq.php#browserwebkitgtk

I cannot get this to work at all. How do I fulfil "WebKitGTK 1.2.0 or newer must be in the library load path"?

Any help much appreciated

like image 612
Phillipus Avatar asked Apr 28 '11 10:04

Phillipus


2 Answers

I'm not on Ubuntu, but think that doesn't matter much.

  1. Check the version of libwebkit-1.0-2 (it should be >= 1.2.0)
  2. Install this package if absent
  3. Check that /usr/lib and /usr/lib/jni is in java.library.path
  4. If you use SWT 3.6, also check that appropriate webkit jni wrapper is installed (e.g. libswt-webkit-gtk-3.6-jni and org.eclipse.swt.browser.UseWebKitGTK system property is set to `True

Edit: To localize source of the problem create minimalistic project and show the output

package foo;

import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class BrowserTest {

    public static void main(String[] args) {

        System.out.println(System.getProperty("java.library.path"));
        System.out.println(System.getProperty("org.eclipse.swt.browser.UseWebKitGTK"));

        Display display = new Display();
        Shell shell = new Shell(display);

        try {
            Browser browser = new Browser(shell, SWT.NONE);
            browser.setSize(shell.getSize());
            browser.setUrl("google.com");
        } catch (SWTError e) {
            e.printStackTrace();
        }

        shell.open();

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }

        display.dispose();

    }
}
like image 114
barti_ddu Avatar answered Nov 15 '22 16:11

barti_ddu


For Eclipse Juno SR1 (4.2 SR1) running on Ubuntu 12.04, the following worked for me:

  1. Install the libwebkit package: sudo apt-get install libwebkitgtk-3.0-0
  2. Install the libwebkit jni wrapper: sudo apt-get install libswt-webkit-gtk-3-jni
  3. Set the DefaultType and UseWebKitGTK properties (I did it by adding the following to my eclipse.ini file):

     -Dorg.eclipse.swt.browser.DefaultType=webkit
     -Dorg.eclipse.swt.browser.UseWebKitGTK=true
    
like image 42
Chris Owens Avatar answered Nov 15 '22 15:11

Chris Owens