Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I want to make SWT use Firefox on all platforms I run my app on. But SWT of course used IE on Windows by default. Any idea how to make SWT use Mozilla on windows. I know that I need to have XULRunner installed on the machine.

like image 942
Bahaa Zaid Avatar asked Jan 18 '10 14:01

Bahaa Zaid


People also ask

How do I make Firefox my default browser in Windows 10?

Windows 10 Go to the Windows Start menu and click the Settings icon. Click Apps, then choose Default Apps on the left pane. Scroll down and click the entry under Web browser. Click on Firefox in the dialog that opens with a list of available browsers.

How do I remove Firefox as my default browser?

You can do that here: "3-bar" menu button (or Tools menu) > Options > General Uncheck the box for "Always check if Firefox is your default browser" Second, open the browser you WANT to be the default browser and use whatever option it has to have it make itself the default.


1 Answers

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.

like image 68
Eugene Avatar answered Oct 14 '22 22:10

Eugene