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.
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.
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.
Funny you've asked - I just needed the same for our project.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With