mozilla

Compare Revisions

Java in Firefox Extensions

Change Revisions

Revision 69934:

Revision 69934 by Brettz9 on

Revision 69935:

Revision 69935 by ignisvulpis on

Title:
Java in Firefox Extensions
Java in Firefox Extensions
Slug:
Java_in_Firefox_Extensions
Java_in_Firefox_Extensions
Tags:
Extensions, Add-ons, Java
Extensions, Add-ons, Java
Content:

Revision 69934
Revision 69935
n8      If you are in need of calling Java code from within a Firefn8      If you are in need of calling Java code from within a Firef
>ox <a href="en/Extension">extension</a>, you can make use of <a c>ox <a href="/en/Extensions" title="en/Extensions">extension</a>, 
>lass="external" href="http://en.wikipedia.org/wiki/LiveConnect">L>you can make use of <a class="external" href="http://en.wikipedia
>iveConnect</a>. LiveConnect gives your extension's JavaScript cod>.org/wiki/LiveConnect">LiveConnect</a>. LiveConnect gives your ex
>e (linked from or contained in XUL code) access to 2 objects: <co>tension's JavaScript code (linked from or contained in XUL code) 
>de>java</code> and <code>Packages</code>. These 2 objects let you>access to 2 objects: <code>java</code> and <code>Packages</code>.
> make use of the standard JDK classes, e.g.,> These 2 objects let you make use of the standard JDK classes, e.
 >g.,
n14      If you want to load your own JARs, then you can create yourn14      If you want to load your own JARs, then you can create your
> own Java class loader, e.g.,> own Java class loader, e.g.,&nbsp;
tt17<span class="kwd">var</span><span class="pln"> urlClasz </span><s
 >pan class="pun">=</span><span class="pln"> java</span><span class
 >="pun">.</span><span class="pln">lang</span><span class="pun">.</
 >span><span class="typ">Class</span><span class="pun">.</span><spa
 >n class="pln">forName</span><span class="pun">(</span><span class
 >="str">"java.net.URL"</span><span class="pun">);</span><span clas
 >s="pln"><br></span><span class="kwd">var</span><span class="pln">
 > urlArray </span><span class="pun">=</span><span class="pln"> jav
 >a</span><span class="pun">.</span><span class="pln">lang</span><s
 >pan class="pun">.</span><span class="pln">reflect</span><span cla
 >ss="pun">.</span><span class="typ">Array</span><span class="pun">
 >.</span><span class="pln">newInstance</span><span class="pun">(</
 >span><span class="pln">urlClasz</span><span class="pun">,</span><
 >span class="lit">1</span><span class="pun">);</span><span class="
 >pln"><br></span><span class="pln">urlArray[0] = </span><span>new 
 >java.net.URL('<a class=" external" href="http://foo.net/bar.jar" 
 >rel="freelink">http://foo.net/bar.jar</a>'</span><span>);<br></sp
 >an>var cl = new java.net.URLClassLoader(<span class="pln">urlArra
 >y);<br><br><br>// </span>javascript array to java array conversio
 >n does not work anymore with plugin2
17var cl = new java.net.URLClassLoader(18//var cl = new java.net.URLClassLoader(
18    [ new java.net.URL('<a class=" external" href="http://foo.net19//    <span style="background-color: rgb(255, 0, 0);">[ new java.
>/bar.jar'" rel="freelink">http://foo.net/bar.jar'</a>) ]>net.URL('<a class=" external" href="http://foo.net/bar.jar'" rel=
 >"freelink">http://foo.net/bar.jar'</a>) ]</span>
19);20//);

Back to History