Re: Accessing Packages from LiveConnect
[email protected] Sat, 01 Sep 2007 00:14:34 -0700
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <1188630874.428867.8520__49958.4660785787$1188630919$gmane$org@w3g2000hsg.googlegroups.com> |
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