Last night I looked at embedded native browser components in Java, focusing on Mac OS X. Tonight we’ll look at what’s available on Windows. There are at least 4 contenders, perhaps more. In addition, there are 3 browser choices: Internet Explorer 5.x/6.x, Mozilla 1.4, and Mozilla 1.7.
First off, there is the Browser component that I talked about last night. Due to the elegance of the Eclipse plug-in loader (actually it is OSGi in 3.x), the name of the component is also called Browser. However, it is in the org.eclipse.swt.win32 plug-in instead of the org.eclipse.swt.carbon plug-in. This is the nicest of the bunch, with the caveat that it only embeds IE 5 or IE 6. Using the SWT Examples that you can download from the main Eclipse download page (look for Example Plug-ins), it worked pretty much like IE. You could even drag URLs to it and it would load them up and update the location bar. On my Windows XP laptop, I’ve got IE 6 installed and using the BrowserSpy information, I confirmed that it was indeed IE 6. Ryan Lowe pointed out that if you have IE 5.x on your Windows, then this component would embed IE 5.x. This came out with Eclipse 3.0.
Eclipse plug-in / RCP developers: I would use this implementation.
Second, we’ve got OLE/ActiveX integration on SWT Windows. I tried this via the SWT Examples again and was unimpressed, but probably because there was more work done in the SWT Browser widget. BrowserSpy couldn’t detect what it was, the location bar didn’t update, though it did otherwise work like IE. This has been around since at least Eclipse 2.x.
Third, there is the JDIC Browser component. This is an AWT component that can nest IE quite easily. There’s a demo available via JNLP. This can also embed Mozilla 1.4 (the whole thing, not Firefox), but you have to jump through some hoops to get there, including setting an environment variable and copying an .exe file. This performed well and the APIs are designed to work cross-platform. The SWT Browser API edges it out for completeness, though. BrowserSpy confirmed IE. This is licensed via LGPL. This project is looking for some help, especially with supporting Mozilla 1.5 and up. BTW, Mozilla 1.4 is around the timeframe of Firefox 0.7 – 0.8. This project started up around the JavaOne 2004 timeframe.
Swing developers: I would use this implementation.
Finally, there is the Webclient. This is another AWT-based implementation that predates the JDIC. This supports Mozilla 1.7 (the whole thing again, not Firefox) only. There is no IE support, but that only makes sense, since this is a collaboration between the Mozilla Foundation and Sun and is hosted at mozilla.org. BrowserSpy confirms that it is Mozilla 1.7. The installation for this was the most heavyweight, due to the reliance of Mozilla 1.7. Nonetheless, this performed decently. This project was started back in 1999 and is licensed with the Mozilla Public License. I suspect that this will either merge with JDIC or be overtaken by JDIC.
One more… JRex supports Mozilla 1.4+ and integrates with AWT/Swing. Haven’t tried this yet, but again, I think JDIC is the project to beat in the AWT/Swing universe.
Linux readers: The only problem is that the list would be almost the same as the one for Windows, except that IE gets the boot, with Mozilla being the only choice for embedding. Also, no OLE/ActiveX. SWT GTK2 3.0 supports Mozilla 1.4 – 1.6 and the 3.1 stream adds support for 1.7.
Update [11/3/2004 10:33PM] – I clarified which browser will be embedded using the SWT Browser widget on Windows. It will be whatever version of IE that is currently installed on your system.