How to make SWT Browser control use Mozilla instead of IE on Windows?

筅森魡賤 提交于 2019-11-27 13:49:33
Eugene

Funny you've asked - I just needed the same for our project.

  1. Go to ATF site (http://wiki.eclipse.org/ATF/Installing) - there's how to d/l XUL Runner from Zend site.
  2. This code will let you run the browser without registering the XULRunner:

Code:

Bundle bundle = Platform.getBundle("org.mozilla.xulrunner"); //$NON-NLS-1$
if (bundle != null) 
{
    URL resourceUrl = bundle.getResource("xulrunner"); //$NON-NLS-1$
    if (resourceUrl != null) {
        try {
            URL fileUrl = FileLocator.toFileURL(resourceUrl);
            File file = new File(fileUrl.toURI());
            System.setProperty("org.eclipse.swt.browser.XULRunnerPath",file.getAbsolutePath()); //$NON-NLS-1$
        } catch (IOException e) {
            // log the exception
        } catch (URISyntaxException e) {
            // log the exception
        }
    }
}

More details here: http://www.eclipse.org/swt/faq.php#howusemozilla

Note: my code is slightly different from FAQ (different plugin ID) - i works for me this way.

Bahaa Zaid

I just found the answer.

  1. You need to have XULRunner registered on your machine. To do so, just unpack it and then execute this command in the command shell xulrunner.exe --register-global.
  2. Pass the SWT.MOZILLA style to Browser constructor: Browser browser = new Browser(shell, SWT.MOZILLA);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!