views:

626

answers:

3

Hi,

I want to write a firefox plugin which will communicate with a java application. The plugin will have to notify the java application of the web page/ url being loaded. The java application will take care of the rest.

Any help or pointers will be much appreciated.

Regards, New to firefox

+2  A: 

I have authored a couple Firefox plugins with precisely this requirement.

One strategy is to use the JavaScript-to-Java bridge in Firefox, which permits the use of Java RMI. I found this approach slow and unstable, and the multithreading is painful.

My current solution is to open a localhost socket and use a textual protocol to communicate. See the XULPlanet developer guide on sockets for how to open and read/write with sockets in Firefox JavaScript, and there's a Sun tutorial on sockets in Java.

The source code to one plugin I wrote (for Firefox and Eclipse) is available under the X11 aka MIT license: Firedoclipse source. Under the lib directory is a component called jsjr, with several Java classes and a JavaScript XPCOM object that implement remote method invocation between Java and JavaScript. The test directory contains some unit tests. This remote method invocation would be overkill for sending only one kind of message in one direction, but you might find the code helpful.

maxg
Thanks for your response. I was hoping that is should be possible to use sockets rather than RMI. Thanks for verifying that.
A: 

I still not got what r u tryin to point out!!! i followed the link u pointed out but its not helpin

A: 

I didn't follow the second step after installing firedoeclipse that is "POINT TO A KEYWORD IN ECLIPSE"