Re: Accessing Packages from LiveConnect
Brett Zamir <[email protected]> Sat, 01 Sep 2007 15:32:49 +0800
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Message-ID | <46D915A1.5080509__29804.8057979488$1188631997$gmane$org@yahoo.com> |
Hello, This appears to be a reply to a reply? (I didn't see the previous reply, if so...) Anyhow, I appreciate very much the response with the details of loading a class.... Thankfully, I was helped out earlier, so I got past that point. However, you may wish to review what I learned at http://developer.mozilla.org/en/docs/Talk:Java_in_Firefox_Extensions to make sure I have worded it out correctly, as I believe it should be helpful for others to know how to do this. Someone else besides myself had asked for a working example before, so I have tried to offer one on this talk page, as well as with other details (such as a way to pass in an argument to the constructor), but it'd be nice for someone more experienced in Java, etc. to to give it a look over to make sure there is not a more efficient way, etc. to do those thigns. best wishes, Brett [email protected] wrote: > On 8 2 , 4 03 , [email protected] wrote: > >> On Jul 9, 9:36 am, Brett Zamir <[email protected]> wrote: >> >> >> >> >> >> >>> Hello, >>> >>> I am trying to get access to Berkeley DB XML's Java classes from within >>> XUL and it doesn't seem to work for me. >>> >>> Whereas I can get the built-in Java packages from XUL with no problem: >>> >>> var abc = java.lang.System.out.println("aaaa"); // Writes >>> sucessfully to the Java Console that I have set to open >>> >>> I have no luck with BDBXML from XUL, even though it is in my CLASSPATH >>> (if that's where it's supposed to be for it to be available): >>> >>> var xmlman = new Packages.com.sleepycat.dbxml.XmlManager(); >>> >>> gives: >>> >>> TypeError: Packages.com.sleepycat.dmxml.XmlManager is not a constructor >>> >>> I've also successfully been able to test what should I believe be the >>> equivalent file in Java (using NetBeans) and there is no problem. >>> >>> import com.sleepycat.dbxml.*; >>> import java.io.*; >>> >>> public class Main { >>> public static void main(String[] args) throws Throwable { >>> try { >>> XmlManager myManager = new XmlManager(); >>> } >>> catch (XmlException e) { >>> System.out.println("XMLexception" + e); >>> } >>> catch (Exception e) { >>> System.out.println("Exception1" + e); >>> } >>> } >>> >>> } >>> >>> thx in advance, >>> Brett >>> >> Hi, I am using a class loader to load external packages. I want to >> load "java lapack classes". Here is a piece of code: >> >> ... >> var fURL = new Array(); >> fURL[1] = new java.net.URL("file:///H:/Devel/NetbeansProjects/ >> JavaLapack/jlapack-0.8/blas_simple.jar"); >> fURL[2] = new java.net.URL("file:///H:/Devel/NetbeansProjects/ >> JavaLapack/jlapack-0.8/f2jutil.jar"); >> fURL[3] = new java.net.URL("file:///H:/Devel/NetbeansProjects/ >> JavaLapack/jlapack-0.8/lapack.jar"); >> fURL[4] = new java.net.URL("file:///H:/Devel/NetbeansProjects/ >> JavaLapack/jlapack-0.8/lapack_simple.jar"); >> fURL[5] = new java.net.URL("file:///H:/Devel/NetbeansProjects/ >> JavaLapack/jlapack-0.8/blas.jar"); >> fURL[6] = new java.net.URL("file:///H:/Devel/NetbeansProjects/ >> JavaLapack/jlapack-0.8/xerbla.jar"); >> >> var loader = new java.net.URLClassLoader(fURL); >> >> var class1 = loader.loadClass("org.netlib.blas.DGEMM"); >> >> var instance1 = class1.newInstance(); >> ... >> >> fURL contains the list of jars where all your classes are. You have to >> load all packages needed by the class(es) that you want to use. Then >> you create a loader, using java.net.URLClassLoader. From that you get >> the class using loader.loadClass and finally you create an instance of >> that class. >> >> Be sure to use file:/// when loading the jars. >> >> m.- - >> >> - - >> > > if doing so, it's too stuffy > > _______________________________________________ > dev-tech-java mailing list > [email protected] > https://lists.mozilla.org/listinfo/dev-tech-java > >