Using WebKit and Eclipse Helios

If you are testing Firefox 4 and also using Eclipse, as I am, then you may have lost your browser capabilities in Eclipse, depending on your installation method. That's because it depends on XulRunner 1.x while Firefox 4 uses Xulrunner 2. I had two good reasons to try out integrating newest Xulrunner into Eclipse: one was because Xulrunner 2 is supposedly faster than it's predecessor and the other one was because I'm a big fan of Mozilla :) (if you want a better second reason, Xulrunner 2 is way too beta to be brought into SWT for Eclipse: it's not even mentioned in Xulrunners site, so I'm not expecting to see it integrated any time soon, not even in the next release of Eclipse as they seem to be moving towards WebKit already).

But trying to make that integration, besides being a pain in the backdoor, seemed to be impossible without major changes to the codebase due to what seems to be severe changes to the API (which I couldn't find documented anywhere). Notably, the nsStaticModuleInfo struct seems to be long gone and that was an entry point for any previous Xulrunner application. I didn't have any previous experience with Xulrunner so I realized (after hours of debugging) that it was going to be too hard for me to work that integration out in a reasonable amount of time (I needed the browser feature to work on my thesis project).

So I finally surrendered and tried out the WebKit method as (somewhat) explained in the SWT FAQ.  I couldn't get it at the first try, so I thought I'd document what I had to do to get it working:

  • The FAQ says you should set a property to true... it doesn't say where. My advice would be to set it in a file called eclipse.ini file located (assuming you install Eclipse by downloading a bundle from the site and unpacking to some directory) at the same directory where the eclipse executable is located, adding a line that reads -Dorg.eclipse.swt.browser.UseWebKitGTK=true at the end of the file.
  • I use IcedTea as my default Java Virtual Machine, but I wasn't able to load the WebKit browser with that configuration because of some strange error so I had to switch to Sun's JavaVM to be able to load the browser. Assuming you are lucky enough to be using a Gentoo based distribution, that's as easy as running eselect java-vm list to list your available Java Virtual Machines and then eselect java-vm set user <n> where n is the number of the Sun JVM.

That's about all the information I have for the moment. I will be investigating all of these issues to see if I can get back to my original idea of rewriting the Xulrunner integration with SWT or at least use an OpenJDK-based Java VM to use WebKit and update this post.