Native Browsers in Java on Windows (and Linux)

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 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.

4 Replies to “Native Browsers in Java on Windows (and Linux)”

  1. I was under the impression that the Eclipse/RCP Browser widget used Windows’ IE widget, which uses whichever version of IE you have installed on that machine, not necessarily IE6. So if you used the Browser widget on an older version of Windows, BrowserSpy might say it’s IE5.

  2. Ryan,

    You’re correct that Eclipse / RCP Browser widget uses whatever IE you have installed in Windows. I forgot to mention that I have IE 6 installed. I’ll update the post to include that info.

  3. Concerning JDIC and other libs relying upon Mozilla, just know that you are not obliged to install Mozilla web suite. You can instead download the Mozilla GRE (Gecko Runtime Environment). As its name states, this package contains only the gecko rendering engine. Now, I’m not sure whether JDIC is able to use this GRE but I used it myself to embed “Mozilla” in several VB and C++ applications.

  4. JDIC Browser component is now supporting Mozilla from 1.4 to 1.7(and later) on Linux/Solaris platform. On Windows, JDIC support IE and mozilla. And, on Windows, the supported version of mozilla depends on the version of mozilla that JDIC is build with. That means if you use mozilla 1.4 or 1.7 to build with jdic, then the jdic binary will support mozilla 1.4 or 1.7 respectively. JDIC team is now try to resolve this versioning dependence problem.
    Now, “you *haven’t* to jump through some hoops to get there”, because JDIC do all this settings automatically.
    The demo on will be updated soon.

Comments are closed.