Which platforms support the SWT Browser, and which native renderers do they use?The SWT Browser is currently available on the platforms listed below. By default, Browser instances created with style
SWT.NONE
use the following native renderers:
- Windows 2000 and newer (Internet Explorer 5.5 and newer)
- Mac OS X 10.5 and newer (WebKit)
- Linux GTK (details)
- Solaris-x86 and Solaris 10 SPARC (details)
SWT.NONE
as this will attempt to use a native renderer that should not require additional software installation. However for clients with specific native browser requirements, the type of native renderer to use can be specified on a per-instance basis, see
How do I explicity use WebKit as the Browser's underlying renderer?
and
How do I explicitly use Mozilla as the Browser's underlying renderer?
.
Also note that as of Eclipse/SWT 3.7 it is possible to override the default native renderer that is used for SWT.NONE
-style Browsers, see How do I specify the default type of native renderer that is used by the Browser?.
As of Eclipse/SWT 3.7.1 a user can set a property to specify the type of native renderer to use for SWT.NONE
-style Browsers. Setting this property does not affect Browsers that are created with styles such as SWT.MOZILLA
or SWT.WEBKIT
. The property name is org.eclipse.swt.browser.DefaultType
and valid values for it currently include "mozilla
" and "webkit
". This property must be set before the first Browser instance is created.
The best opportunity for a user to set this property is by launching their application with a -D
VM switch (eg.- add to the end of the eclipse.ini file: -Dorg.eclipse.swt.browser.DefaultType=webkit
).
An alternate approach that an eclipse application may use is to provide a BrowserInitializer
implementation that sets this property. This implementation will be invoked when the first Browser instance is about to be created. The steps to do this are:
- Create a fragment with host plug-in
org.eclipse.swt
. - In this fragment create class
org.eclipse.swt.browser.BrowserInitializer
. - Implement a static initializer in this class that sets the
org.eclipse.swt.browser.DefaultType
property.
- Eclipse 3.7.x/4.1.x: Mozilla 1.4 GTK2 - 1.7.x GTK2, XULRunner 1.8.x - 3.6.x, WebKitGTK+ 1.2.x and newer
- Eclipse 3.8.x/4.2.x: Mozilla 1.4 GTK2 - 1.7.x GTK2, XULRunner 1.8.x - 3.6.x and 10.x (but not versions 4.x - 9.x), WebKitGTK+ 1.2.x and newer
SWT.WEBKIT
(
@since 3.7
). The runtime requirements for using WebKit-based Browsers are listed below. Note that failure to meet these runtime requirements will cause the Browser instantiation to fail.
- Windows:
- 32-bit SWT
- Safari must be installed
- For OSs older than XP+SP1, the path to the Apple Application Support installation must be prepended to Windows' "Path" environment variable before running eclipse. This installation will be in a location like "
C:\Program Files\Common Files\Apple\Apple Application Support
".
- Linux: WebKitGTK 1.2.0 or newer must be in the library load path. Examples of Linux distros that meet this requirement by default include Red Hat Enterprise Linux 6 and Ubuntu 10.04.
- OS X: No additional runtime requirements, the default renderer is WebKit-based.
It is important to note that conflicts have been reported between the dependent libraries of WebKit and Mozilla. As a result it is advised that Browser instances with these respective types not be mixed in an application. If a Browser with one of these types must be used in an application then java property org.eclipse.swt.browser.DefaultType
should also be set to this type to ensure that SWT.NONE
-style Browsers do not cause the libraries from the other native browser renderer to be loaded (see How do I specify the default type of native renderer that is used by the Browser?).
How do I use the WebKit renderer on Linux-GTK?
A: In Eclipse/SWT 3.7 and newer the Browser attempts to use WebKitGTK for SWT.NONE-style Browsers created on GTK. For this to succeed, WebKitGTK 1.2.0 or newer must be in the library load path. Examples of Linux distros that meet this requirement by default include Red Hat Enterprise Linux 6 and Ubuntu 10.04. Linux installations that do not meet this requirement will fall back to using Mozilla for SWT.NONE-style Browsers.
Eclipse/SWT 3.6.x can also use WebKitGTK for SWT.NONE-style Browsers created on GTK, but the user must explicitly request this by setting java property "org.eclipse.swt.browser.UseWebKitGTK
" to "true
". In the absence of this property being set, Mozilla is used for all SWT.NONE-style Browsers. (Note that Eclipse/SWT 3.6.x is only able to use WebKitGTK 1.2.x; it will fail if a newer WebKitGTK release is found.)
How can I determine which installed Mozilla browser is being used to render Browser content?
import org.eclipse.swt.SWT; import org.eclipse.swt.browser.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; public class DisplayMozillaVersion { public static void main(String[] args) { Device.DEBUG = true; Display display = new Display(); Shell shell = new Shell(display); System.out.println(">>>Snippet creating SWT.MOZILLA-style Browser"); try { new Browser(shell, SWT.MOZILLA); System.out.println(">>>succeeded"); } catch (Error e) { System.out.println(">>>This failed with the following error:"); e.printStackTrace(); System.out.println("\n\nSnippet creating SWT.NONE-style Browser"); try { new Browser(shell, SWT.NONE); System.out.println(">>>succeeded"); } catch (Error e2) { System.out.println(">>>This failed too, with the following error:"); e2.printStackTrace(); } } display.dispose(); } }