On Jan 19, 4:47 pm, tlrobinson <[EMAIL PROTECTED]> wrote: > On Jan 19, 12:40 pm, Norris Boyd <[EMAIL PROTECTED]> wrote: > > > On Jan 19, 7:00 am, tlrobinson <[EMAIL PROTECTED]> wrote: > > > I too am wondering how to use external libraries with Rhino. I've > > > tried putting the .jar in my classpath and using the > > > java.com.domain.packagename syntax, but no such luck. > > > > Thank you. > > > If you have a class com.foo.Bar, then you load it by > > "Packages.com.foo.Bar". "java.com.foo.Bar" would only work if your > > class was really a subpackage of "java". > > > 1.7 will include a top-level definition for "com", among others. Once > > 1.7 is released you'll be able to load com.foo.Bar using com.foo.Bar. > > > --N > > I'm trying to use Xerces: > > js> var doc = new Packages.org.apache.xerces.dom.DocumentImpl(); > js: "<stdin>", line 2: uncaught JavaScript runtime exception: > TypeError: [JavaPackage org.apache.xerces.dom.DocumentImpl] is not a > function, it is org.mozilla.javascript.NativeJavaPackage. > > xercesImpl.jar is in my classpath, and the equivalent in Java works > fine: > > org.w3c.dom.Document doc = new > org.apache.xerces.dom.DocumentImpl(); > > Thanks for your help.
The error you're getting indicates that Rhino can't load the class org.apache.xerces.dom.DocumentImpl. I tried it, with success: [rhino] java -classpath "build/rhino1_7R1/js.jar;../../../downloads/ xalan-j_2_7_1/xercesImpl.jar" org.mozilla.javascript.tools.shell.Main Rhino 1.7 release 1 2008 01 19 js> new Packages.org.apache.xerces.dom.DocumentImpl() [#document: null] --N _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
