Re: Why does JavaXPCOM require XULRunner?

Brett Zamir <[email protected]> Thu, 14 Feb 2008 00:23:28 +0800
Newsgroups gmane.comp.mozilla.devel.java
Message-ID <[email protected]>
Jack Smith wrote:
> Hey guys,
>
> This question has probably been asked a million times, but after searching
> the archives I didn't find anything: Is it possible to use JavaXPCOM to make
> Java apps communicate with Firefox extensions, or is it truly
> XULRunner-only?
>
> I made a sidebar Firefox extension to act as the GUI for a command-line Java
> app I wrote. The only problem is that the communication is one-way -- I can
> use nsIProcess to launch the .jar file from the extension, but it can't
> receive any information back as the app is running!
>   

One tip with LiveConnect... while it is very easy to use, there is a bug 
with try-catch that requires you to handle exceptions on the Java-side 
rather than JavaScript side.  I've reported this bug at 
https://bugzilla.mozilla.org/show_bug.cgi?id=391642 (even the 
documentation example (which Michal referred you to) in the try-catch 
section has an example which doesn't work anymore).

Incidentally, is there anyone else who wants this bug quashed? Maybe 
some feedback (or vote) on the bug would be suitable.

I have already encountered several prominent developers and even a large 
database corporation working with XML who've indicated they'd really 
like to have available the code that could easily be created in 
LiveConnect if this one try-catch bug were fixed.

For example, using Saxon-B, Javascript could have access to its XPath, 
but also XSLT 2.0, and XQuery. I'm implemented them in my own 
extensions, but the need to write wrapper classes to catch the 
exceptions makes exposing the full API prohibitive, at least in any way 
that I can tell.

Brett