LiveConnect and/or JavaXPCOM
poorboywilly <[email protected]> Mon, 1 Dec 2008 11:24:51 -0800 (PST)
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <a36154b4-1882-4acf-98b9-baf1bbb849e2@i20g2000prf.googlegroups.com> |
Hi guys, I'm having a bear of a time here trying to work with some
Java code. I've got an extension going in Firefox (the XUL,
JavaScript, CSS is great) and an XPCOM component in C++ (my best
language) to do most of the heavy lifting. The last thing I need to
do is interface with a Java library (Apache's Nutch) for a few calls.
Having discovered JavaXPCOM and LiveConnect this seemed like cake, but
the documentation is definitely spotty so when my own fiddling doesn't
work I can't find anywhere to turn.
First, I already implemented an XPCOM component in C++ so I decided to
do a Java XPCOM component. I have the XULRunner 1.9 SDK which
includes the Java interfaces for all the nsISupports and so forth. I
implemented ISupports, IModule, IFactory in a few Java classes as well
as defined my own interface in an IDL, compiling the idl both to
a .java file and a typelib. All the JavaXPCOM stuff I can find deals
almost entirely with calling XPCOM components from Java code, I cannot
find info on a Java component. I've tried putting the raw class files
(and typelib) in the Firefox/components directory, as well as a .jar
of my classes in there and Firefox won't seem to find the component
like it does my C++ component (using XPCOMViewer extension). What am
I missing with the JavaXPCOM?
Then, I stumbled across LiveConnect, and I could seemingly create the
Nutch Java classes in my JavaScript extension code with a simple "new
Packages.foo.bar.Class()" statement. I was able to create a "new
java.lang.String("foo")", which had me excited. But the only
apparently useful documentation I can find on LiveConnect is using it
to call code in applets (e.g. https://jdk6.dev.java.net/plugin2/liveconnect/).
Well, I don't need an applet, I just need to call an arbitrary Java
package, and not even from a website, from an extension. Perhaps I'm
asking for too much? I found a vague reference to placing the
desired .jar in the jre/lib/ext folder, which I did, but when I do
that the LiveConnect statement just seems to freeze the browser. Can
LiveConnect be used in this way?
I would appreciate ANY help anyone can throw at this.
thanks,
--Jason