Java Firefox Extension

What is this?

This is a Firefox extension that demonstrates how you can use Java inside a Firefox extension. We have used this technique in our Piggy Bank extension. This extension distills the technique to a skeleton so that you can more easily comprehend.

This is intended for Firefox extension developers only.

Get the Code and Build It

You can browse the code online or you can follow these steps to download and build it yourself.

Here is a list of things you need to build Java Firefox Extension:

How to build it:

  1. cd where/you/want/it
  2. svn checkout java-firefox-extension
  3. cd java-firefox-extension
  4. ant

This will create a distribution in the ./dist directory that contains everything and a packaged version java-firefox-extension-[version].xpi in the same folder. This XPI package is a zip package that is recognized by firefox as an extension.

For some tips on extension development, refer to Developers' Guide for Piggy Bank.

Play with The Extension

Once you install the extension in Firefox (and restart Firefox), you can open up Firefox's JavaScript console (from the Tools menu) and see the extension's messages:

    FooComponent.initialize {
    FooComponent._bootstrapClassLoader {
    } FooComponent._bootstrapClassLoader
    FooComponent._loadJava {
    } FooComponent._loadJava
    Greetings: Hello World!
    } FooComponent.initialize
This tells you that the extension has been successful at loading its own Java code. Then you can try to invoke Firefox's menu Tools → Java Firefox Extension: Do It!. You should get a dialog box displaying 43. Subsequent invocations increment that number.

Explore the Code

These are some steps enough for you to start exploring the code:

Licensing & Legal Issues

Java Firefox Extension is open source software and is licensed under the BSD license.


This software is maintained by the SIMILE project and in particular: