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

萝らか妹 提交于 2019-11-30 00:50:50

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();

    }
}
Chris Owens

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
    

Simply installing the "hotot" (Twitter) App via Software Center, which drags WebKit along, did the trick for me. - A "sudo apt-get install -y libwebkitgtk-1.0-0", or build from source as per https://help.ubuntu.com/community/WebKit, would probably work as well.

For Natty, check out this page: http://www.maplef.net/blog/archives/ubuntu-upgrade-eclipse3-5-to-3-6.html (ignore japanses/chinese stuff, just follow the code to reach shangri-la)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!