Search code examples
javaringojs

How can I import my own .class file into a RingoJS application?


Good day,

I would like to know how I could import and call my library contained in a .jar file directly through RingoJS.

Thank you.

Edit:

Here is some additional informations. I have compiled a class named xsltProcessor that uses the SAXON library into a .JAR file. That class has a method named transform( xml file source, xslt file source ). That is the class and method I would like to use in RingoJS.


Solution

  • First, you'll have to add your library (the .jar file) to the classpath, either via Java's classpath or via adding it at runtime from within Ringo, using addToClasspath. See Ringo's Java integration wiki page for more detail.

    Then, you can just use the classes contained within that library using Rhino's Packages.<java.package.name> and related features for scripting Java. Read Rhino's Scripting Java documentation for the details.