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.
Asked
Active
Viewed 1.1k times
2 Answers
7
Funny you've asked - I just needed the same for our project.
- Go to ATF site (http://wiki.eclipse.org/ATF/Installing) - there's how to d/l XUL Runner from Zend site.
- 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.
-
old. outdated. deprecated. – Chexpir May 07 '15 at 16:54
5
I just found the answer.
- 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
. - Pass the
SWT.MOZILLA
style to Browser constructor:Browser browser = new Browser(shell, SWT.MOZILLA);

Favonius
- 13,959
- 3
- 55
- 95

Bahaa Zaid
- 1,449
- 2
- 16
- 22
-
I am this error, can't find the solution: java.lang.UnsatisfiedLinkError: org.eclipse.swt.internal.mozilla.init.XPCOMInit.GREVersionRange_sizeof()I – Chexpir May 07 '15 at 16:56
-
2When I run `xulrunner.exe --register-global`, it tells me that `Error: couldn't parse application.ini`. – kenshinji Dec 06 '16 at 05:34